[ 'class' => VerbFilter::class, 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], ] ], ], ]; } public function actionAdd(int $idProducer) { $userProducerManager = $this->getUserProducerManager(); $producer = $this->findProducer($idProducer); $userCurrent = $this->getUserCurrent(); $this->getLogic()->setProducerContext($producer); $userProducerManager->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) { $userProducerManager = $this->getUserProducerManager(); $producer = $this->findProducer($idProducer); $userCurrent = $this->getUserCurrent(); $this->getLogic()->setProducerContext($producer); $userProducerManager->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) { $producerManager = $this->getProducerManager(); $producer = $producerManager->findOneProducerById($idProducer); if($producer) { return $producer; } else { throw new NotFoundHttpException('Producteur introuvable.'); } } }