1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hosting Plugin for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
6
|
|
|
* @package hipanel-module-hosting |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\grid; |
12
|
|
|
|
13
|
|
|
use hipanel\grid\BoxedGridView; |
14
|
|
|
use hipanel\grid\DataColumn; |
15
|
|
|
use hipanel\grid\RefColumn; |
16
|
|
|
use hipanel\grid\XEditableColumn; |
17
|
|
|
use hipanel\modules\hosting\menus\PrefixActionsMenu; |
18
|
|
|
use hipanel\modules\hosting\models\Prefix; |
19
|
|
|
use hiqdev\yii2\menus\grid\MenuColumn; |
20
|
|
|
use Yii; |
21
|
|
|
use yii\helpers\Html; |
22
|
|
|
use yii\helpers\IpHelper; |
23
|
|
|
|
24
|
|
|
class PrefixGridView extends BoxedGridView |
25
|
|
|
{ |
26
|
|
|
public function columns() |
27
|
|
|
{ |
28
|
|
|
return array_merge(parent::columns(), [ |
29
|
|
|
'ip' => [ |
30
|
|
|
'format' => 'html', |
31
|
|
|
'value' => static function (Prefix $prefix) { |
32
|
|
|
return Html::a($prefix->ip, ['@prefix/view', 'id' => $prefix->id], ['class' => 'text-bold']); |
|
|
|
|
33
|
|
|
}, |
34
|
|
|
], |
35
|
|
|
'state' => [ |
36
|
|
|
'class' => RefColumn::class, |
37
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
38
|
|
|
'format' => 'raw', |
39
|
|
|
'gtype' => 'state,ip', |
40
|
|
|
], |
41
|
|
|
'type' => [ |
42
|
|
|
'class' => RefColumn::class, |
43
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
44
|
|
|
'format' => 'raw', |
45
|
|
|
'gtype' => 'type,ip', |
46
|
|
|
], |
47
|
|
|
'vrf' => [ |
48
|
|
|
'class' => RefColumn::class, |
49
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
50
|
|
|
'format' => 'raw', |
51
|
|
|
'gtype' => 'type,ip_vrf', |
52
|
|
|
], |
53
|
|
|
'role' => [ |
54
|
|
|
'class' => RefColumn::class, |
55
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
56
|
|
|
'format' => 'raw', |
57
|
|
|
'gtype' => 'type,ip_prefix_role', |
58
|
|
|
], |
59
|
|
|
'site' => [ |
60
|
|
|
'class' => RefColumn::class, |
61
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
62
|
|
|
'format' => 'raw', |
63
|
|
|
'gtype' => 'type,location', |
64
|
|
|
], |
65
|
|
|
'family' => [ |
66
|
|
|
'class' => DataColumn::class, |
67
|
|
|
'label' => Yii::t('hipanel.hosting.ipam', 'Family'), |
68
|
|
|
'value' => static function ($model) { |
69
|
|
|
return sprintf('IPv%d', IpHelper::getIpVersion($model->ip)); |
70
|
|
|
} |
71
|
|
|
], |
72
|
|
|
'utilization' => [ |
73
|
|
|
'class' => UtilizationColumn::class, |
74
|
|
|
], |
75
|
|
|
'note' => [ |
76
|
|
|
'class' => XEditableColumn::class, |
77
|
|
|
'pluginOptions' => [ |
78
|
|
|
'url' => 'set-note', |
79
|
|
|
], |
80
|
|
|
'filter' => true, |
81
|
|
|
'popover' => Yii::t('hipanel', 'Make any notes for your convenience'), |
82
|
|
|
], |
83
|
|
|
'actions' => [ |
84
|
|
|
'class' => MenuColumn::class, |
85
|
|
|
'contentOptions' => ['style' => 'width: 1%; white-space:nowrap;'], |
86
|
|
|
'menuClass' => PrefixActionsMenu::class, |
87
|
|
|
], |
88
|
|
|
]); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.