Completed
Push — master ( 055fd1...11841d )
by Klochok
24:15 queued 09:17
created

DbGridView   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 62
ccs 0
cts 57
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A columns() 0 59 1
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-2016, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\grid;
12
13
use hipanel\grid\ActionColumn;
14
use hipanel\grid\BoxedGridView;
15
use hipanel\grid\MainColumn;
16
use hipanel\grid\RefColumn;
17
use hipanel\grid\XEditableColumn;
18
use hipanel\modules\hosting\widgets\backup\BackupGridRow;
19
use hipanel\modules\hosting\widgets\db\State;
20
use hipanel\modules\server\grid\ServerColumn;
21
use Yii;
22
23
class DbGridView extends BoxedGridView
24
{
25
    public function columns()
26
    {
27
        return array_merge(parent::columns(), [
28
            'name'          => [
29
                'class'           => MainColumn::class,
30
                'format' => 'html',
31
                'attribute'       => 'name',
32
                'filterAttribute' => 'name_like',
33
            ],
34
            'state'       => [
35
                'class'  => RefColumn::class,
36
                'i18nDictionary' => 'hipanel:hosting',
37
                'format' => 'raw',
38
                'value'  => function ($model) {
39
                    return State::widget(compact('model'));
40
                },
41
                'gtype'  => 'state,db',
42
            ],
43
            'account' => [
44
                'class' => AccountColumn::class,
45
            ],
46
            'server'      => [
47
                'class' => ServerColumn::class,
48
            ],
49
            'service_ip'  => [
50
                'filter' => false,
51
            ],
52
            'description' => [
53
                'class' => XEditableColumn::class,
54
                'pluginOptions' => [
55
                    'url' => 'set-description',
56
                ],
57
                'filter'  => true,
58
                'popover' => Yii::t('hipanel', 'Make any notes for your convenience'),
59
            ],
60
            'password' => [
61
                'class' => XEditableColumn::class,
62
                'pluginOptions' => [
63
                    'url' => 'set-password',
64
                ],
65
                'filter'  => true,
66
                'popover' => Yii::t('hipanel', 'Change password'),
67
                'value'   => function () {
68
                    return Yii::t('hipanel', 'Change password');
69
                },
70
            ],
71
            'backups_widget' => [
72
                'label' => Yii::t('hipanel:hosting', 'Backups'),
73
                'format' => 'raw',
74
                'value' => function ($model) {
75
                    return BackupGridRow::widget(['model' => $model]);
76
                },
77
            ],
78
            'actions'     => [
79
                'class'    => ActionColumn::class,
80
                'template' => '{view} {delete}',
81
            ],
82
        ]);
83
    }
84
}
85