| Conditions | 4 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 6.5971 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | 1 | public function actionIndex() |
|
| 14 | { |
||
| 15 | 1 | $model = new SettingsForm(); |
|
| 16 | |||
| 17 | 1 | if (Yii::$app->request->isPost) { |
|
| 18 | Yii::$app->response->format = 'json'; |
||
| 19 | |||
| 20 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
||
| 21 | Yii::$app->settings->load($model->getAttributes()); |
||
| 22 | |||
| 23 | Yii::$app->session->setFlash('success', Yii::t('app.msg', 'Saved successfully')); |
||
| 24 | return $this->refresh(); |
||
| 25 | } |
||
| 26 | return $this->asJsonModelErrors($model); |
||
| 27 | } |
||
| 28 | |||
| 29 | 1 | $model->setAttributes(Yii::$app->settings->all()); |
|
| 30 | |||
| 31 | 1 | return $this->render('index', ['model' => $model]); |
|
| 32 | } |
||
| 33 | } |
||
| 34 |