|
123456789101112131415161718192021222324252627 |
- <?php
-
- namespace common\logic;
-
- use common\logic\Producer\Producer\Model\Producer;
- use yii\base\ErrorException;
-
- trait ProducerContextTrait
- {
- protected ?Producer $producerContext = null;
-
- public function setProducerContext(Producer $producer): self
- {
- $this->producerContext = $producer;
-
- return $this;
- }
-
- public function getProducerContext(): Producer
- {
- if(is_null($this->producerContext)) {
- throw new ErrorException("Le contexte producteur n'est pas défini.");
- }
-
- return $this->producerContext;
- }
- }
|