protected function beforeAction($action) { parent::beforeAction($action); if (\Yii::app()->user->isGuest) { if ($action->id == 'login') { return true; } $this->redirect(Yii::app()->createUrl('login')); } else { return true; } }
/** * @param \CAction $action * @return bool */ protected function beforeAction($action) { /** * $this->module->getId() !== 'install' избавляет от ошибок на этапе установки * $this->id !== 'backend' || ($this->id == 'backend' && $action->id != 'modupdate') устраняем проблемы с зацикливанием */ if (($this->id !== 'backend' || $this->id == 'backend' && $action->id != 'modupdate') && ($updates = Yii::app()->migrator->checkForUpdates([$this->module->getId() => $this->module])) !== null && count($updates) > 0) { Yii::app()->getUser()->setFlash(YFlashMessages::WARNING_MESSAGE, Yii::t('YupeModule.yupe', 'You must install all migration before start working with module.')); $this->redirect(['/yupe/backend/modupdate', 'name' => $this->module->getId()]); } return parent::beforeAction($action); }