Passed
Push — master ( f7a351...988e81 )
by Alexey
03:10
created

DefaultController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 46
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 16 2
A actionIndex() 0 3 1
A actionInit() 0 6 2
1
<?php
2
3
namespace modules\rbac\controllers;
4
5
use Yii;
6
use yii\helpers\Url;
7
use yii\filters\AccessControl;
8
use yii\filters\VerbFilter;
9
use modules\rbac\Module;
10
11
/**
12
 * Class DefaultController
13
 * @package modules\rbac\controllers
14
 */
15
class DefaultController extends \modules\rbac\console\InitController
16
{
17
    /**
18
     * @inheritdoc
19
     * @return array
20
     */
21
    public function behaviors()
22
    {
23
        return [
24
            'access' => [
25
                'class' => AccessControl::className(),
0 ignored issues
show
Deprecated Code introduced by
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

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

25
                'class' => /** @scrutinizer ignore-deprecated */ AccessControl::className(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
26
                'rules' => [
27
                    [
28
                        'allow' => true,
29
                        'roles' => ['managerRbac'],
30
                    ],
31
                ],
32
            ],
33
            'verbs' => [
34
                'class' => VerbFilter::className(),
0 ignored issues
show
Deprecated Code introduced by
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

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

34
                'class' => /** @scrutinizer ignore-deprecated */ VerbFilter::className(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
35
                'actions' => [
36
                    'init' => YII_ENV_TEST ? ['GET'] : ['POST'],
37
                ],
38
            ],
39
        ];
40
    }
41
42
    /**
43
     * Renders the index view for the module
44
     * @return mixed
45
     */
46
    public function actionIndex()
47
    {
48
        return $this->render('index');
49
    }
50
51
    /**
52
     * Переинициализация RBAC
53
     * с установкой настроек по умолчанию
54
     */
55
    public function actionInit()
56
    {
57
        if ($this->processInit()) {
58
            Yii::$app->session->setFlash('success', Module::t('module', 'The operation was successful!'));
59
        }
60
        Yii::$app->getResponse()->redirect(Url::to(['index']));
61
    }
62
}
63