AccountColumn   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 31
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 17 4
A getDataCellValue() 0 4 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-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\grid;
12
13
use hipanel\modules\hosting\widgets\combo\AccountCombo;
14
use hiqdev\higrid\DataColumn;
15
use yii\helpers\Html;
16
17
class AccountColumn extends DataColumn
18
{
19
    public $attribute = 'account_id';
20
21
    public $nameAttribute = 'account';
22
23
    public $format = 'html';
24
25
    public function init()
26
    {
27
        parent::init();
28
29
        if (!empty($this->grid->filterModel)) {
30
            if (!$this->filterInputOptions['id']) {
31
                $this->filterInputOptions['id'] = $this->attribute;
32
            }
33
            if (!$this->filter) {
34
                $this->filter = AccountCombo::widget([
35
                    'attribute'           => $this->attribute,
36
                    'model'               => $this->grid->filterModel,
37
                    'formElementSelector' => 'td',
38
                ]);
39
            }
40
        }
41
    }
42
43
    public function getDataCellValue($model, $key, $index)
44
    {
45
        return Html::a($model->{$this->nameAttribute}, ['@account/view', 'id' => $model->{$this->attribute}]);
46
    }
47
}
48