Completed
Push — master ( f52782...055fd1 )
by Klochok
26:48 queued 11:52
created

CrontabGridView::columns()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
ccs 0
cts 35
cp 0
rs 8.8571
cc 1
eloc 26
nc 1
nop 0
crap 2
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\modules\hosting\menus\CrontabActionsMenu;
14
use hipanel\modules\server\grid\ServerColumn;
15
use hiqdev\yii2\menus\grid\MenuColumn;
16
use Yii;
17
use yii\helpers\Html;
18
19
class CrontabGridView extends \hipanel\grid\BoxedGridView
20
{
21
    public function columns()
22
    {
23
        return array_merge(parent::columns(), [
24
            'crontab' => [
25
                'attribute' => 'crontab',
26
                'format' => 'html',
27
                'enableSorting' => false,
28
                'value' => function ($model, $key, $index) {
0 ignored issues
show
Unused Code introduced by
The parameter $index is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
                    $label = Yii::t('hipanel:hosting', '{0, plural, one{# record} other{# records}}', $model->cronRecordCount);
30
                    return Html::a($label, ['view', 'id' => $key], ['class' => 'bold', 'data-pjax' => 0]);
31
                },
32
            ],
33
            'server' => [
34
                'sortAttribute' => 'server',
35
                'attribute' => 'server_id',
36
                'class' => ServerColumn::class,
37
            ],
38
            'account' => [
39
                'sortAttribute' => 'account',
40
                'attribute' => 'account_id',
41
                'class' => AccountColumn::class,
42
            ],
43
            'client',
44
            'state' => [
45
                'enableSorting' => false,
46
                'attribute' => 'state',
47
                'value' => function ($model) {
48
                    return Yii::t('hipanel:hosting:cron:states', $model->state);
49
                },
50
            ],
51
            'actions' => [
52
                'class' => MenuColumn::class,
53
                'menuClass' => CrontabActionsMenu::class,
54
            ],
55
        ]);
56
    }
57
}
58