1 | <?php |
||||||
2 | |||||||
3 | use yii\grid\GridView; |
||||||
4 | use yii\helpers\{Url, Html}; |
||||||
5 | use Itstructure\RbacModule\Module; |
||||||
6 | use Itstructure\RbacModule\models\PermissionSearch; |
||||||
7 | |||||||
8 | /* @var $this yii\web\View */ |
||||||
9 | /* @var $roles Itstructure\RbacModule\models\Permission */ |
||||||
10 | /* @var $dataProvider yii\data\ArrayDataProvider */ |
||||||
11 | /* @var $searchModel PermissionSearch */ |
||||||
12 | |||||||
13 | $this->title = Module::t('permissions', 'Permissions'); |
||||||
14 | $this->params['breadcrumbs'][] = $this->title; |
||||||
15 | ?> |
||||||
16 | <div class="permission-index"> |
||||||
17 | |||||||
18 | <p> |
||||||
19 | <?php echo Html::a(Module::t('permissions', 'Create permission'), [ |
||||||
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('permissions', '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
![]() |
|||||||
38 | 'id' => $item->name |
||||||
39 | ]) |
||||||
40 | ); |
||||||
41 | }, |
||||||
42 | 'format' => 'raw', |
||||||
43 | ], |
||||||
44 | 'description' => [ |
||||||
45 | 'label' => Module::t('permissions', 'Description'), |
||||||
46 | 'value' => function($item) { |
||||||
47 | return $item->description; |
||||||
48 | }, |
||||||
49 | 'format' => 'raw', |
||||||
50 | ], |
||||||
51 | 'permissions' => [ |
||||||
52 | 'label' => Module::t('permissions', 'Permissions'), |
||||||
53 | 'value' => function($item) use ($searchModel) { |
||||||
54 | |||||||
55 | /* @var $searchModel PermissionSearch */ |
||||||
56 | $permissions = $searchModel->authManager->getChildren($item->name); |
||||||
57 | |||||||
58 | if (empty($permissions)) {return Module::t('permissions', 'No permissions');} |
||||||
59 | |||||||
60 | return implode('<br>', array_map(function ($data) { |
||||||
61 | |||||||
62 | return Html::a($data->name, Url::to([ |
||||||
63 | '/'.$this->params['urlPrefix'].'view', |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
64 | 'id' => $data->name |
||||||
65 | ]), |
||||||
66 | [ |
||||||
67 | 'target' => '_blank' |
||||||
68 | ]); |
||||||
69 | |||||||
70 | }, $permissions)); |
||||||
71 | }, |
||||||
72 | 'format' => 'raw', |
||||||
73 | ], |
||||||
74 | [ |
||||||
75 | 'class' => 'yii\grid\ActionColumn', |
||||||
76 | 'header' => Module::t('main', 'Actions'), |
||||||
77 | 'template' => '{view} {update} {delete}', |
||||||
78 | '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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
79 | return Url::to([ |
||||||
80 | $this->params['urlPrefix'].$action, |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
81 | 'id' => $model->name |
||||||
82 | ]); |
||||||
83 | } |
||||||
84 | ], |
||||||
85 | ], |
||||||
86 | ]); ?> |
||||||
87 | |||||||
88 | </div> |
||||||
89 |