Completed
Push — master ( f04bdf...03085f )
by Andrii
05:00
created

ConfigDetailMenu::items()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 22
ccs 0
cts 14
cp 0
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hipanel\modules\server\menus;
4
5
use Yii;
6
7
class ConfigDetailMenu extends \hipanel\menus\AbstractDetailMenu
8
{
9
    public $model;
10
11
    public function items()
12
    {
13
        $actions = ConfigActionsMenu::create(['model' => $this->model])->items();
14
        $items = array_merge($actions, [
15
            'delete' => [
16
                'label' => Yii::t('hipanel', 'Delete'),
17
                'icon' => 'fa-trash',
18
                'url' => ['@config/delete', 'id' => $this->model->id],
19
                'encode' => false,
20
                'visible' => Yii::$app->user->can('config.delete'),
0 ignored issues
show
Bug introduced by
The method can() does not exist on null. ( Ignorable by Annotation )

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

20
                'visible' => Yii::$app->user->/** @scrutinizer ignore-call */ can('config.delete'),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
21
                'linkOptions' => [
22
                    'data' => [
23
                        'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'),
24
                        'method' => 'POST',
25
                        'pjax' => '0',
26
                    ],
27
                ],
28
            ],
29
        ]);
30
        unset($items['view']);
31
32
        return $items;
33
    }
34
}
35