| Conditions | 6 |
| Paths | 8 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | public function run() |
||
| 31 | { |
||
| 32 | /* @var $model \yii\db\ActiveRecord */ |
||
| 33 | $model = new $this->modelClass(); |
||
| 34 | if ($this->scenario) { |
||
| 35 | $model->setScenario($this->scenario); |
||
| 36 | } |
||
| 37 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
||
| 38 | foreach ($model->toArray() as $key => $value) { |
||
| 39 | Yii::$app->settings->set($key, $value, $model->formName()); |
||
| 40 | } |
||
| 41 | Yii::$app->getSession()->addFlash('success', |
||
|
|
|||
| 42 | Module::t('settings', 'Successfully saved settings on {section}', |
||
| 43 | ['section' => $model->formName()] |
||
| 44 | ) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | foreach ($model->attributes() as $key) { |
||
| 48 | $model->{$key} = Yii::$app->settings->get($key, $model->formName()); |
||
| 49 | } |
||
| 50 | return $this->controller->render($this->viewName, ['model' => $model]); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: