Completed
Push — master ( 007929...7c1f43 )
by Andrii
12:21
created

ServerDetailMenu   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 53
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B items() 0 41 2
A getViewPath() 0 4 1
1
<?php
2
3
namespace hipanel\modules\server\menus;
4
5
use hiqdev\menumanager\Menu;
6
use Yii;
7
8
class ServerDetailMenu extends Menu
9
{
10
    public $model;
11
12
    public $blockReasons;
13
14
    public function items()
15
    {
16
        $actions = ServerActionsMenu::create(['model' => $this->model])->items();
17
        $items = array_merge($actions, [
18
            [
19
                'label' => Yii::t('hipanel:server', 'Renew server'),
20
                'icon' => 'fa-forward',
21
                'url' => ['add-to-cart-renewal', 'model_id' => $this->model->id],
22
                'linkOptions' => [
23
                    'data-pjax' => 0,
24
                ],
25
            ],
26
            [
27
                'label' => $this->renderView('_reset-password', ['model' => $this->model]),
28
                'visible' => $this->model->isPwChangeSupported(),
29
                'encode' => false,
30
            ],
31
            [
32
                'label' => Yii::t('hipanel:server', 'Resources usage graphs'),
33
                'icon' => 'fa-signal',
34
                'url' => ['@rrd/view', 'id' => $this->model->id],
35
            ],
36
            [
37
                'label' => Yii::t('hipanel:server', 'Switch graphs'),
38
                'icon' => 'fa-area-chart',
39
                'url' => ['@switch-graph/view', 'id' => $this->model->id],
40
            ],
41
            [
42
                'label' => $this->renderView('_block', ['model' => $this->model, 'blockReasons' => $this->blockReasons]),
43
                'visible' => Yii::$app->user->can('support') && Yii::$app->user->not($this->model->client_id),
44
                'encode' => false,
45
            ],
46
            [
47
                'label' => $this->renderView('_delete', ['model' => $this->model]),
48
                'encode' => false,
49
                'visible' => Yii::$app->user->can('support'),
50
            ],
51
        ]);
52
53
        return $items;
54
    }
55
56
    public function getViewPath()
57
    {
58
        return '@vendor/hiqdev/hipanel-module-server/src/views/server';
59
    }
60
}
61