|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
-
-
-
- namespace backend\controllers;
-
- use common\controllers\CommonController;
- use common\logic\PointSale\PointSale\Model\PointSale;
- use common\logic\Producer\Producer\Model\Producer;
- use common\logic\Product\Product\Model\Product;
-
- class BackendController extends CommonController
- {
- public function beforeAction($event)
- {
- $producerCurrent = $this->getProducerCurrent();
-
-
- if($producerCurrent) {
- $this->getLogic()->setProducerContext($producerCurrent);
- }
-
-
- if(!$producerCurrent) {
- $this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index']));
- return false;
- }
-
- return parent::beforeAction($event);
- }
-
-
-
- public function checkProductsPointsSale()
- {
- if (!Product::searchCount() || !PointSale::searchCount()) {
- $this->redirect(['site/index', 'error_products_points_sale' => 1]);
- }
- }
-
- public function getProducerCurrent(): ?Producer
- {
- return Producer::searchOne();
- }
- }
-
- ?>
|