[ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => [ 'login', 'error', ], 'allow' => true, ], [ 'actions' => [ 'logout', 'index', ], 'allow' => true, 'roles' => [ '@' ], ], ], ], ]; } /** * @inheritdoc */ public function getViewPath() { return \Yii::getAlias('@artbox/core/views/settings'); } /** * Display site settings page * * @return string|\yii\web\Response */ public function actionIndex() { $model = $this->findSettings(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', 'Settings saved'); return $this->goHome(); } return $this->render( 'settings', [ 'model' => $model, ] ); } /** * Find site settings * * @return \yii2tech\filedb\ActiveRecord * @throws \yii\base\InvalidConfigException */ public function findSettings() { if ($model = Settings::find() ->one() ) { return $model; } else { throw new InvalidConfigException('Settings file not found'); } } }