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

RbacController::actionShow()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 0
cts 13
cp 0
rs 9.4285
cc 3
eloc 9
nc 4
nop 0
crap 12
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