|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
-
-
-
- namespace backend\controllers\admin;
-
- use backend\controllers\BackendController;
- use backend\forms\AdminSettingsForm;
- use yii\filters\AccessControl;
-
-
- class SettingAdminController extends BackendController
- {
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => AccessControl::class,
- 'rules' => [
- [
- 'allow' => true,
- 'roles' => ['@'],
- 'matchCallback' => function ($rule, $action) {
- return $this->getUserModule()
- ->getAuthorizationChecker()
- ->isGrantedAsAdministrator($this->getUserCurrent());
- }
- ]
- ],
- ],
- ];
- }
-
- public function actionIndex()
- {
- $settingModule = $this->getSettingModule();
- $model = new AdminSettingsForm();
- if($model->load(\Yii::$app->request->post()) && $model->validate()) {
- foreach($settingModule->getAdminSettingDefinition()->getSettingDetailsFlat() as $settingDetail) {
- $settingModule->getAdminSettingBag()->set($settingDetail->getName(), $model->{$settingDetail->getName()});
- }
- }
-
- return $this->render('index', [
- 'model' => $model
- ]);
- }
- }
|