You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?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;
- }
-
- public function getProducerContextId()
- {
- return $this->getProducerContext()->id;
- }
- }
|