getUserCurrent()) { return $this->redirectProducerLoginFrontend('index'); } return $this->render('index', [ 'user' => $this->getUserCurrent(), 'producer' => $this->getProducerCurrent() ]); } public function actionSubscribe() { if(!$this->getUserCurrent()) { return $this->redirectProducerLoginFrontend('subscribe'); } $userModule = $this->getUserModule(); $userCurrent = $this->getUserCurrent(); $userModule->subscribeUserNewsletter($userCurrent); //$this->setFlash('success', " Votre inscription à l'infolettre a bien été prise en compte."); return $this->redirect('index'); } public function actionUnsubscribe() { if(!$this->getUserCurrent()) { return $this->redirectProducerLoginFrontend('unsubscribe'); } $userModule = $this->getUserModule(); $userCurrent = $this->getUserCurrent(); $userModule->unsubscribeUserNewsletter($userCurrent); //$this->setFlash('success', " Votre désinscription a bien été prise en compte, vous ne recevrez plus d'infolettre de la part de ce producteur."); return $this->redirect('index'); } public function actionReportProblemReceivingEmails() { if(!$this->getUserCurrent()) { return $this->redirectProducerLoginFrontend('index'); } if(!$this->getUserModule()->getManager()->reportProblemReceivingEmails($this->getUserCurrent())) { $this->setFlash('error', "Une erreur est survenue."); } return $this->redirect('index'); } public function redirectProducerLoginFrontend(string $actionNewsletter) { return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $this->getProducerCurrent()->id, 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['newsletter/'.$actionNewsletter, 'slug_producer' => $this->getProducerCurrent()->slug])])); } } ?>