getProducerCurrent(); if($producerCurrent) { $this->getLogic()->setProducerContext($producerCurrent); } if(!$producerCurrent) { $this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['dashboard/index'])); return false; } return parent::beforeAction($event); } /** * Vérifie si l'utilisateur a au moins saisi un produit et un point de vente. * Si ce n'est pas le cas : redirection vers le tableau de bord. */ public function checkProductsPointsSale() { if (!Product::searchCount() || !PointSale::searchCount()) { $this->redirect(['dashboard/index', 'error_products_points_sale' => 1]); } } public function getProducerCurrent(): ?Producer { return Producer::searchOne(); } public function redirectDashboard() { return $this->redirect(['dashboard/index']); } public function redirectAfterSave(string $baseRoute, int $id) { $postParams = \Yii::$app->request->post(); if(isset($postParams['save-stay'])) { return $this->redirect([$baseRoute.'/update', 'id' => $id]); } else { return $this->redirect(['index']); } } } ?>