Completed
Push — master ( 2d333a...ab0ccf )
by Andrii
03:57
created

RbacController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 3
dl 0
loc 26
ccs 0
cts 19
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actionInit() 0 7 1
A actionShow() 0 15 3
1
<?php
2
3
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\rbac\console;
13
14
use hipanel\rbac\Initer;
15
use Yii;
16
use yii\rbac\Item;
17
18
/**
19
 * Class RbacController.
20
 *
21
 * Usage: ./hidev rbac/init
22
 */
23
class RbacController extends \yii\console\Controller
24
{
25
    public function actionInit()
26
    {
27
        $auth = Yii::$app->get('authManager');
28
        $auth->setAssignment('freezer', 'sol');
29
30
        Initer::init($auth);
31
    }
32
33
    public function actionShow()
34
    {
35
        $auth = Yii::$app->get('authManager');
36
37
        echo "Permissions:\n";
38
        foreach ($auth->getItems(Item::TYPE_PERMISSION) as $name => $perm) {
39
            echo "\t$perm->name $perm->description\n";
40
        }
41
42
        echo "Roles:\n";
43
        foreach ($auth->getItems(Item::TYPE_ROLE) as $name => $role) {
44
            $children = implode(',', array_keys($auth->getChildren($name)));
45
            echo "\t$role->name [$children] $role->description\n";
46
        }
47
    }
48
}
49