Issues (213)

src/menus/HubDetailMenu.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
11
namespace hipanel\modules\server\menus;
12
13
use hipanel\menus\AbstractDetailMenu;
14
use hipanel\widgets\AjaxModalWithTemplatedButton;
15
use Yii;
16
use yii\helpers\Html;
17
18
class HubDetailMenu extends AbstractDetailMenu
19
{
20
    public $model;
21
22
    public function items(): array
23
    {
24
        $actions = HubActionsMenu::create(['model' => $this->model])->items();
25
        $items = array_merge($actions, [
26
            'delete' => [
27
                'label' => Yii::t('hipanel', 'Delete'),
28
                'icon' => 'fa-trash',
29
                'url' => ['@hub/delete', 'id' => $this->model->id],
30
                'encode' => false,
31
                'visible' => Yii::$app->user->can('hub.delete'),
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

31
                'visible' => Yii::$app->user->/** @scrutinizer ignore-call */ can('hub.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...
32
                'linkOptions' => [
33
                    'data' => [
34
                        'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'),
35
                        'method' => 'POST',
36
                        'pjax' => '0',
37
                    ],
38
                ],
39
            ],
40
            'monitoring-settings' => [
41
                'label' => AjaxModalWithTemplatedButton::widget([
42
                    'ajaxModalOptions' => [
43
                        'id' => "monitoring-settings-modal-{$this->model->id}",
44
                        'bulkPage' => true,
45
                        'header' => Html::tag('h4', Yii::t('hipanel:server', 'Monitoring properties'), ['class' => 'modal-title']),
46
                        'scenario' => 'default',
47
                        'actionUrl' => ['monitoring-settings', 'id' => $this->model->id],
48
                        'handleSubmit' => ['monitoring-settings', 'id' => $this->model->id],
49
                        'toggleButton' => [
50
                            'tag' => 'a',
51
                            'label' => Html::tag('span', Html::tag('i', null, ['class' => 'fa fa-fw fa-area-chart']), ['class' => 'pull-right']) . Yii::t('hipanel:server', 'Monitoring properties'),
52
                            'style' => 'cursor: pointer;',
53
                        ],
54
                    ],
55
                    'toggleButtonTemplate' => '{toggleButton}',
56
                ]),
57
                'encode' => false,
58
                'visible' => Yii::$app->user->can('server.manage-settings'),
59
            ],
60
        ]);
61
        unset($items['view']);
62
63
        return $items;
64
    }
65
}
66