Issues (1313)

controllers/admin/SettingController.php (5 issues)

1
<?php
2
3
namespace app\controllers\admin;
4
5
use Yii;
6
use app\traits\{LanguageTrait, AdminBeforeActionTrait, AccessTrait};
7
use Itstructure\AdminModule\controllers\AdminController;
8
9
/**
10
 * Class SettingController
11
 * SettingController implements the CRUD actions for Setting model.
12
 *
13
 * @package app\controllers\admin
14
 */
15
class SettingController extends AdminController
16
{
17
    use LanguageTrait, AdminBeforeActionTrait, AccessTrait;
0 ignored issues
show
The trait app\traits\AccessTrait requires the property $user which is not provided by app\controllers\admin\SettingController.
Loading history...
The trait app\traits\AdminBeforeActionTrait requires the property $controller which is not provided by app\controllers\admin\SettingController.
Loading history...
18
19
    /**
20
     * List of records.
21
     *
22
     * @return string
23
     */
24
    public function actionIndex()
25
    {
26
        if (!$this->checkAccessToAdministrate()) {
27
            return $this->accessError();
28
        }
29
30
        /* @var $model \app\models\Setting */
31
        $model = Yii::$app->get('settings')
32
            ->setModel()
33
            ->getSettings();
34
35
        if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post()) && $model->save()) {
0 ignored issues
show
It seems like Yii::app->request->post() can also be of type object; however, parameter $data of yii\base\Model::load() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
        if (Yii::$app->request->isPost && $model->load(/** @scrutinizer ignore-type */ Yii::$app->request->post()) && $model->save()) {
Loading history...
36
            return $this->redirect([
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->redirect(a...e . '/admin/settings')) returns the type yii\web\Response which is incompatible with the documented return type string.
Loading history...
37
                '/'.$this->shortLanguage.'/admin/settings'
38
            ]);
39
        }
40
41
        $fields = [
42
            'model' => $model,
43
            'roles' => Yii::$app->authManager->getRoles()
0 ignored issues
show
The method getRoles() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
            'roles' => Yii::$app->authManager->/** @scrutinizer ignore-call */ getRoles()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        ];
45
46
        return $this->render('index', $fields);
47
    }
48
}
49