/** * @inheritdoc */ public function beforeAction($action) { if (parent::beforeAction($action)) { $componentClassName = \Yii::$app->request->get('componentClassName'); $namespace = \Yii::$app->request->get('componentNamespace'); if ($namespace) { $component = new $componentClassName(['namespace' => $namespace]); } else { $component = new $componentClassName(); } if (!$component || !$component instanceof Component) { throw new UserException("Указан некорректный компонент"); } if (!$component->existsConfigFormFile()) { throw new UserException("У компонента не задана форма для управления настройками"); } $this->_component = $component; return true; } else { return false; } }
/** * @inheritdoc */ public function beforeAction($action) { if (parent::beforeAction($action)) { $componentClassName = \Yii::$app->request->get('componentClassName'); $namespace = \Yii::$app->request->get('componentNamespace'); if ($namespace) { $component = new $componentClassName(['namespace' => $namespace]); } else { $component = new $componentClassName(); } if (!$component || !$component instanceof Component) { throw new UserException("Указан некорректный компонент"); } $this->_component = $component; $this->_callableData = $this->_getCallableData($component); //TODO: Добавить возможность настройки \Yii::$app->view->theme = new Theme(['pathMap' => ['@app/views' => ['@skeeks/cms/modules/admin/views']]]); \Yii::$app->language = \Yii::$app->admin->languageCode; return true; } else { return false; } }
/** * @param \yii\base\Action $action * @return bool * @throws \yii\web\BadRequestHttpException */ public function beforeAction($action) { if (parent::beforeAction($action)) { if ($action instanceof AdminOneModelEditAction) { if ($this->model !== null) { return true; } else { //throw new NotFoundHttpException('Не найдено'); $this->redirect($this->getIndexUrl()); } } return true; } else { return false; } }