[ 'class' => VerbFilter::class, 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], ] ], ], ]; } public function actionAdd(int $idProducer) { $userProducerModule = $this->getUserProducerModule(); $producer = $this->findProducer($idProducer); $userCurrent = $this->getUserCurrent(); $this->getLogic()->setProducerContext($producer); $userProducerModule->addProducerBookmark($userCurrent); $this->setFlash('success', 'Le producteur ' . Html::encode($producer->name) . ' vient d\'être ajouté à votre liste de producteurs.'); return $this->redirectReferer(); } public function actionRemove(int $idProducer) { $userProducerModule = $this->getUserProducerModule(); $producer = $this->findProducer($idProducer); $userCurrent = $this->getUserCurrent(); $this->getLogic()->setProducerContext($producer); $userProducerModule->removeProducerBookmark($userCurrent); $this->setFlash('success', 'Le producteur ' . Html::encode($producer->name) . ' vient d\'être supprimé de votre liste de producteurs.'); return $this->redirectReferer(); } public function findProducer(int $idProducer) { $producerModule = $this->getProducerModule(); $producer = $producerModule->findOneProducerById($idProducer); if($producer) { return $producer; } else { throw new NotFoundHttpException('Producteur introuvable.'); } } }