|
- <?php
-
-
-
- namespace common\controllers;
-
- use common\components\BusinessLogic;
- use common\components\BusinessLogicTrait;
- use common\components\ParameterBag;
- use domain\User\User\User;
- use yii;
- use yii\web\Response;
-
- class CommonController extends \yii\web\Controller
- {
- use BusinessLogicTrait;
-
- public function beforeAction($event)
- {
- if (!Yii::$app->user->isGuest) {
- $this->getUserModule()->updateUserLastConnection(Yii::$app->user->identity);
- }
-
- return parent::beforeAction($event);
- }
-
- public function actionMaintenance()
- {
- return $this->renderFile('@common/views/maintenance.php');
- }
-
- public function getLogic(): BusinessLogic
- {
- return Yii::$app->logic;
- }
-
- public function getUrlManagerProducer()
- {
- return Yii::$app->urlManagerProducer;
- }
-
- public function getUrlManagerFrontend()
- {
- return Yii::$app->urlManagerFrontend;
- }
-
- public function getUrlManagerBackend()
- {
- return Yii::$app->urlManagerBackend;
- }
-
- public function getUserCurrent(): ?User
- {
- return Yii::$app->user->identity;
- }
-
- public function isUserCurrentAdmin()
- {
- return $this->getUserModule()->isAdmin($this->getUserCurrent());
- }
-
- public function getRequest()
- {
- return Yii::$app->request;
- }
-
- public function setFlash($key, $value = true, $removeAfterAccess = true): void
- {
- Yii::$app->session->setFlash($key, $value, $removeAfterAccess);
- }
-
- public function addFlash($key, $value = true, $removeAfterAccess = true): void
- {
- Yii::$app->session->addFlash($key, $value, $removeAfterAccess);
- }
-
- public function redirectReferer(): Response
- {
- return $this->redirect(Yii::$app->request->referrer ?: Yii::$app->homeUrl);
- }
-
- public function getParameterBag(): ParameterBag
- {
- return Yii::$app->parameterBag;
- }
- }
-
- ?>
|