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\RefColumn; |
14
|
|
|
use hipanel\modules\hosting\menus\RequestActionsMenu; |
15
|
|
|
use hipanel\modules\hosting\models\Request; |
16
|
|
|
use hipanel\modules\server\grid\ServerColumn; |
17
|
|
|
use hipanel\widgets\gridLegend\ColorizeGrid; |
18
|
|
|
use hiqdev\yii2\menus\grid\MenuColumn; |
19
|
|
|
use Yii; |
20
|
|
|
use yii\helpers\Html; |
21
|
|
|
use yii\helpers\UnsetArrayValue; |
22
|
|
|
|
23
|
|
|
class RequestGridView extends \hipanel\grid\BoxedGridView |
24
|
|
|
{ |
25
|
|
|
use ColorizeGrid; |
26
|
|
|
|
27
|
|
|
public function columns() |
28
|
|
|
{ |
29
|
|
|
return array_merge(parent::columns(), [ |
30
|
|
|
'classes' => [ |
31
|
|
|
'label' => Yii::t('hipanel:hosting', 'Action'), |
32
|
|
|
'filter' => false, |
33
|
|
|
'enableSorting' => false, |
34
|
|
|
'value' => function ($model) { |
35
|
|
|
return sprintf('%s, %s', $model->object_class, $model->action); |
36
|
|
|
}, |
37
|
|
|
], |
38
|
|
|
'server' => class_exists(ServerColumn::class) ? [ |
39
|
|
|
'sortAttribute' => 'server', |
40
|
|
|
'attribute' => 'server_id', |
41
|
|
|
'class' => ServerColumn::class, |
42
|
|
|
] : [ |
43
|
|
|
'visible' => false, |
44
|
|
|
], |
45
|
|
|
'account' => [ |
46
|
|
|
'enableSorting' => false, |
47
|
|
|
'class' => AccountColumn::class, |
48
|
|
|
], |
49
|
|
|
'object' => [ |
50
|
|
|
'enableSorting' => false, |
51
|
|
|
'filter' => false, |
52
|
|
|
'format' => 'raw', |
53
|
|
|
'value' => function (Request $model): string { |
54
|
|
|
return Html::a('<i class="fa fa-external-link"></i> ' . $model->object, |
|
|
|
|
55
|
|
|
['/hosting/' . $model->object_class . '/view', 'id' => $model->object_id], |
|
|
|
|
56
|
|
|
['data-pjax' => 0] |
57
|
|
|
); |
58
|
|
|
}, |
59
|
|
|
], |
60
|
|
|
'time' => [ |
61
|
|
|
'filter' => false, |
62
|
|
|
'value' => function ($model) { |
63
|
|
|
return Yii::$app->formatter->asDatetime($model->time); |
64
|
|
|
}, |
65
|
|
|
], |
66
|
|
|
'state' => [ |
67
|
|
|
'class' => RefColumn::class, |
68
|
|
|
'i18nDictionary' => 'hipanel:hosting', |
69
|
|
|
'gtype' => 'state,request', |
70
|
|
|
'format' => 'raw', |
71
|
|
|
'value' => function ($model) { |
72
|
|
|
$colors = [ |
73
|
|
|
'error' => 'danger', |
74
|
|
|
'progress' => 'info', |
75
|
|
|
'done' => 'success', |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
return Html::tag('span', Yii::t('hipanel:hosting', $model->state_label), [ |
79
|
|
|
'class' => 'text-' . (isset($colors[$model->state]) ? $colors[$model->state] : 'default'), |
80
|
|
|
]); |
81
|
|
|
}, |
82
|
|
|
'filterOverrides' => [ |
83
|
|
|
'done' => new UnsetArrayValue(), |
84
|
|
|
], |
85
|
|
|
], |
86
|
|
|
'parent' => [ |
87
|
|
|
'format' => 'raw', |
88
|
|
|
'value' => function (Request $model): string { |
89
|
|
|
return Html::a($model->parent, ['@request/view', 'id' => $model->parent_id]); |
|
|
|
|
90
|
|
|
}, |
91
|
|
|
], |
92
|
|
|
'actions' => [ |
93
|
|
|
'class' => MenuColumn::class, |
94
|
|
|
'menuClass' => RequestActionsMenu::class, |
95
|
|
|
], |
96
|
|
|
]); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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.