ComboXEditable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 38
c 0
b 0
f 0
ccs 0
cts 24
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 24 2
A registerAssets() 0 5 1
1
<?php
2
/**
3
 * X-editable extension for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-x-editable
6
 * @package   yii2-x-editable
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\xeditable\widgets;
12
13
use hipanel\helpers\ArrayHelper;
14
use hiqdev\combo\Combo;
15
use hiqdev\xeditable\assets\ComboXEditableAsset;
16
use Yii;
17
18
class ComboXEditable extends XEditable
19
{
20
    /**
21
     * @var array|Combo
22
     */
23
    public $combo;
24
25
    public function init()
26
    {
27
        parent::init();
28
29
        if (!$this->combo instanceof Combo) {
30
            $this->combo = ArrayHelper::merge([
31
                'model' => $this->model,
32
                'attribute' => $this->attribute,
33
            ], $this->combo);
34
35
            $this->combo = Yii::createObject($this->combo);
36
        }
37
38
        $this->combo->registerClientConfig();
39
40
        $this->pluginOptions = ArrayHelper::merge([
41
            'type' => 'combo',
42
            'placement' => 'bottom',
43
            'combo' => $this->combo->getPluginOptions(),
44
            'hash' => $this->combo->configId,
45
        ], $this->pluginOptions);
46
47
        $this->registerAssets();
48
    }
49
50
    public function registerAssets()
51
    {
52
        parent::registerAssets();
53
        ComboXEditableAsset::register(Yii::$app->view);
54
    }
55
}
56