diff --git a/backend/controllers/SettingsController.php b/backend/controllers/SettingsController.php new file mode 100755 index 0000000..f9885f1 --- /dev/null +++ b/backend/controllers/SettingsController.php @@ -0,0 +1,79 @@ + [ + 'class' => AccessControl::className(), + 'rules' => [ + [ + 'actions' => [ + 'login', + 'error', + ], + 'allow' => true, + ], + [ + 'actions' => [ + 'logout', + 'index', + ], + 'allow' => true, + 'roles' => [ '@' ], + ], + ], + ], + ]; + } + /** + * @return bool|string + */ + public function getViewPath() + { + return \Yii::getAlias('@artbox/core/views/settings'); + } + + 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, + ] + ); + } + + public function findSettings() + { + if ($model = Settings::find() + ->one() + ) { + return $model; + } else { + throw new ConfigurationException('Settings file not found'); + } + } + } \ No newline at end of file diff --git a/backend/views/settings/settings.php b/backend/views/settings/settings.php new file mode 100755 index 0000000..99b3a61 --- /dev/null +++ b/backend/views/settings/settings.php @@ -0,0 +1,57 @@ +title = 'Settings'; + + $this->params[ 'breadcrumbs' ][] = $this->title; +?> + + $this->title, + 'toolbar' => false, + ] +); ?> + +