Issues (213)

src/menus/ConfigActionsMenu.php (1 issue)

1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
namespace hipanel\modules\server\menus;
11
12
use Yii;
13
14
class ConfigActionsMenu extends \hiqdev\yii2\menus\Menu
15
{
16
    public $model;
17
18
    public function items()
19
    {
20
        return [
21
            'view' => [
22
                'label' => Yii::t('hipanel', 'View'),
23
                'icon' => 'fa-info',
24
                'url' => ['@config/view', 'id' => $this->model->id],
25
                'visible' => Yii::$app->user->can('config.read'),
0 ignored issues
show
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

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

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...
26
            ],
27
            'update' => [
28
                'label' => Yii::t('hipanel', 'Update'),
29
                'icon' => 'fa-pencil',
30
                'url' => ['@config/update', 'id' => $this->model->id],
31
                'visible' => Yii::$app->user->can('config.update'),
32
            ],
33
            'enable' => [
34
                'label' => Yii::t('hipanel', 'Enable'),
35
                'icon' => 'fa-toggle-on',
36
                'url' => ['@config/enable', 'id' => $this->model->id],
37
                'linkOptions' => [
38
                    'data' => [
39
                        'confirm' => Yii::t('hipanel', 'Are you sure you want to enable this item?'),
40
                        'method' => 'POST',
41
                        'pjax' => '0',
42
                    ],
43
                ],
44
                'visible' => Yii::$app->user->can('config.update') && $this->model->state != 'ok',
45
            ],
46
            'disable' => [
47
                'label' => Yii::t('hipanel', 'Disable'),
48
                'icon' => 'fa-toggle-off',
49
                'url' => ['@config/disable', 'id' => $this->model->id],
50
                'linkOptions' => [
51
                    'data' => [
52
                        'confirm' => Yii::t('hipanel', 'Are you sure you want to disable this item?'),
53
                        'method' => 'POST',
54
                        'pjax' => '0',
55
                    ],
56
                ],
57
                'visible' => Yii::$app->user->can('config.update') && $this->model->state !== 'disabled',
58
            ],
59
            'delete' => [
60
                'label' => Yii::t('hipanel', 'Delete'),
61
                'icon' => 'fa-trash',
62
                'url' => ['@config/delete', 'id' => $this->model->id],
63
                'linkOptions' => [
64
                    'data' => [
65
                        'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'),
66
                        'method' => 'POST',
67
                        'pjax' => '0',
68
                    ],
69
                ],
70
                'visible' => Yii::$app->user->can('config.delete'),
71
            ],
72
        ];
73
    }
74
}
75