Issues (42)

src/views/roles/index.php (5 issues)

1
<?php
2
3
use yii\grid\GridView;
4
use yii\helpers\{Url, Html};
5
use Itstructure\RbacModule\Module;
6
use Itstructure\RbacModule\models\RoleSearch;
7
8
/* @var $this yii\web\View */
9
/* @var $roles Itstructure\RbacModule\models\Role */
10
/* @var $dataProvider yii\data\ArrayDataProvider */
11
/* @var $searchModel RoleSearch */
12
13
$this->title = Module::t('roles', 'Roles');
14
$this->params['breadcrumbs'][] = $this->title;
15
?>
16
<div class="role-index">
17
18
    <p>
19
        <?php echo Html::a(Module::t('roles', 'Create role'), [
20
            $this->params['urlPrefix'].'create'
21
        ], [
22
            'class' => 'btn btn-success'
23
        ]) ?>
24
    </p>
25
26
27
    <?php echo GridView::widget([
28
        'dataProvider' => $dataProvider,
29
        'columns' => [
30
31
            'name' => [
32
                'label' => Module::t('roles', 'Name'),
33
                'value' => function($item) {
34
                    return Html::a(
35
                        Html::encode($item->name),
36
                        Url::to([
37
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
38
                            'id' => $item->name
39
                        ])
40
                    );
41
                },
42
                'format' => 'raw',
43
            ],
44
            [
45
                'attribute' => 'description',
46
                'label' =>  Module::t('roles', 'Description'),
47
            ],
48
            'permissions' => [
49
                'label' => Module::t('roles', 'Permissions'),
50
                'value' => function($item) use ($searchModel) {
51
52
                    /* @var $searchModel RoleSearch */
53
                    $permissions = $searchModel->authManager->getPermissionsByRole($item->name);
54
55
                    if (empty($permissions)) {return Module::t('roles', 'No permissions');}
56
57
                    return implode('<br>', array_map(function ($data) {
58
59
                        return Html::a($data->name, Url::to([
60
                            '/'.$this->params['urlPrefixNeighbor'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
61
                            'id' => $data->name
62
                        ]),
63
                            [
64
                                'target' => '_blank'
65
                            ]);
66
67
                    }, $permissions));
68
                },
69
                'format' => 'raw',
70
            ],
71
            [
72
                'class' => 'yii\grid\ActionColumn',
73
                'header' => Module::t('main', 'Actions'),
74
                'template' => '{view} {update} {delete}',
75
                'urlCreator' => function($action, $model, $key, $index){
0 ignored issues
show
The parameter $index is not used and could be removed. ( Ignorable by Annotation )

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

75
                'urlCreator' => function($action, $model, $key, /** @scrutinizer ignore-unused */ $index){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

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

75
                'urlCreator' => function($action, $model, /** @scrutinizer ignore-unused */ $key, $index){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
                    return Url::to([
77
                        $this->params['urlPrefix'].$action,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
78
                        'id' => $model->name
79
                    ]);
80
                }
81
            ],
82
        ],
83
    ]); ?>
84
85
</div>
86