MultiSelectListBox   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A registerPlugin() 0 15 3
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-multiselect-widget project.
5
 * (c) 2amigOS! <http://2amigos.us/>
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace dosamigos\multiselect;
11
12
use yii\base\InvalidParamException;
13
use yii\helpers\Json;
14
15
/**
16
 * MultiSelectListBox renders a [Louis Cuny Multiselect listbox widget](http://loudev.com/)
17
 *
18
 * @see http://loudev.com/
19
 * @author Antonio Ramirez <[email protected]>
20
 * @link http://www.ramirezcobos.com/
21
 * @link http://www.2amigos.us/
22
 * @package dosamigos\multiselect
23
 */
24
class MultiSelectListBox extends MultiSelect
25
{
26
    /**
27
     * Registers MultiSelect JQuery plugin and the related events
28
     * @throws InvalidParamException
29
     */
30
    public $options=['multiple'=>'multiple'];
31
    
32
    protected function registerPlugin()
33
    {
34
        $view = $this->getView();
35
36
        MultiSelectListBoxAsset::register($view);
37
38
        $id = $this->options['id'];
39
40
        $options = $this->clientOptions !== false && !empty($this->clientOptions)
41
            ? Json::encode($this->clientOptions)
42
            : '';
43
44
        $js = "jQuery('#$id').multiSelect($options);";
45
        $view->registerJs($js);
46
    }
47
}
48