Issues (42)

src/views/profiles/index.php (6 issues)

1
<?php
2
3
use yii\grid\GridView;
4
use yii\helpers\{Html, Url};
5
use Itstructure\RbacModule\Module;
6
use Itstructure\RbacModule\interfaces\RbacIdentityInterface;
7
8
/* @var $this yii\web\View */
9
/* @var $searchModel RbacIdentityInterface */
10
/* @var $dataProvider yii\data\ActiveDataProvider */
11
12
$this->title = Module::t('profiles', 'Profiles');
13
$this->params['breadcrumbs'][] = $this->title;
14
?>
15
<div class="profile-index">
16
17
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
18
19
    <?php echo GridView::widget([
20
        'dataProvider' => $dataProvider,
21
        //'filterModel' => $searchModel,
22
        'columns' => [
23
            [
24
                'label' => Module::t('main', 'ID'),
25
                'value' => function($searchModel) {
26
                    return Html::a(
27
                        Html::encode($searchModel->id),
28
                        Url::to([
29
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
30
                            'id' => $searchModel->id
31
                        ])
32
                    );
33
                },
34
                'format' => 'raw',
35
            ],
36
            [
37
                'label' => Module::t('profiles', 'Name'),
38
                'value' => function($searchModel) {
39
                    return Html::a(
40
                        Html::encode($searchModel->userName),
41
                        Url::to([
42
                            $this->params['urlPrefix'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
43
                            'id' => $searchModel->id
44
                        ])
45
                    );
46
                },
47
                'format' => 'raw',
48
            ],
49
            [
50
                'label' => Module::t('profiles', 'Roles'),
51
                'value' => function($searchModel) {
52
                    /* @var $searchModel RbacIdentityInterface */
53
                    $roles = $searchModel->getRoles();
54
55
                    if (empty($roles)) {return Module::t('profiles', 'No roles');}
56
57
                    return implode('<br>', array_map(function ($data) {
58
59
                        return Html::a($data, 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
62
                        ]),
63
                        [
64
                            'target' => '_blank'
65
                        ]);
66
67
                    }, array_keys($roles)));
68
                },
69
                'format' => 'raw',
70
            ],
71
            [
72
                'attribute' => 'created_at',
73
                'label' => Module::t('main', 'Created date'),
74
                'format' =>  ['date', 'dd.MM.YY HH:mm:ss'],
75
            ],
76
            [
77
                'attribute' => 'updated_at',
78
                'label' => Module::t('main', 'Updated date'),
79
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
80
            ],
81
            [
82
                'class' => 'yii\grid\ActionColumn',
83
                'header' => Module::t('main', 'Actions'),
84
                'template' => '{view} {update} {delete}',
85
                'urlCreator'=>function($action, $model, $key, $index){
0 ignored issues
show
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

85
                '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...
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

85
                '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...
86
                    return Url::to([
87
                        $this->params['urlPrefix'].$action,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
88
                        'id' => $model->id
89
                    ]);
90
                }
91
            ],
92
        ]
93
    ]); ?>
94
</div>
95