Completed
Push — master ( c1fce6...6de931 )
by Alexey
02:42
created

ControlSidebar   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 2
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 5 2
A registerAssets() 0 10 2
1
<?php
2
3
namespace backend\widgets\control;
4
5
use yii\bootstrap\Widget;
6
use yii\web\JsExpression;
7
8
/**
9
 * Class ControlSidebar
10
 * @package backend\themes\AdminLTE\widgets
11
 */
12
class ControlSidebar extends Widget
13
{
14
    /**
15
     * @var bool
16
     */
17
    public $status = true;
18
19
    /**
20
     * @var bool
21
     */
22
    public $demo = false;
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function run()
28
    {
29
        if ($this->status === true) {
30
            $this->registerAssets();
31
            echo $this->render('controlSidebar');
32
        }
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function registerAssets()
39
    {
40
        $view = $this->getView();
41
        $script = new JsExpression("
42
            $('a[href=\"#control-sidebar-home-tab\"]').parent().removeClass('active');
43
            $('#control-sidebar-home-tab').removeClass('active');
44
        ");
45
        if ($this->demo === true) {
46
            DemoAsset::register($view);
47
            $view->registerJs($script);
48
        }
49
    }
50
}
51