Completed
Pull Request — master (#126)
by
unknown
22:33 queued 07:02
created

ApplyToAllWidget   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 5
dl 0
loc 29
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 13 1
1
<?php
2
3
4
namespace hipanel\widgets;
5
6
7
use hipanel\assets\ApplyToAllAsset;
8
use yii\base\Widget;
9
10
/**
11
 * Class AssignAttributesWidget
12
 * @package hipanel\widgets
13
 */
14
class ApplyToAllWidget extends Widget
15
{
16
    /**
17
     * @var \hipanel\base\Model[]
18
     */
19
    public $models;
20
21
    /**
22
     * @var string[]
23
     */
24
    public $attributes;
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function run()
30
    {
31
        ApplyToAllAsset::register($this->view);
32
        $options = \yii\helpers\Json::htmlEncode([
33
            'countModels' => count($this->models),
34
            'formName' => strtolower(reset($this->models)->formName()),
35
            'attributes' => $this->attributes,
36
            'linkText' => \Yii::t('hipanel', 'Apply to all'),
37
        ]);
38
        $this->view->registerJs("\$('#assign-hubs-form').applyToAll($options);");
39
40
        return parent::run();
41
    }
42
}
43