Completed
Push — master ( 8e4a64...521cc3 )
by Paweł
04:47
created

ProxyAlert::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 05.02.2018
6
 */
7
8
namespace app\modules\admin\widgets;
9
10
11
use app\models\Proxy;
12
use dmstr\widgets\Alert;
13
use yii\bootstrap\Alert as BootstrapAlert;
14
use yii\helpers\Html;
15
16
class ProxyAlert extends Alert
17
{
18
19
    public function init()
20
    {
21
        parent::init();
22
        $this->options['class'] = $this->alertTypes['danger']['class'];
23
        $this->options['id'] = $this->getId() . '-danger';
24
    }
25
26
    public function run()
27
    {
28
        if (Proxy::find()->active()->exists()) {
29
            return null;
30
        }
31
32
        $message = Html::a('Add at least one proxy <span class="fa fa-angle-double-right"></span>', ['proxy/create']);
33
34
        echo "<section class=\"content-header\">";
35
        echo BootstrapAlert::widget([
36
            'body' => $this->alertTypes['warning']['icon'] . $message,
37
            'closeButton' => false,
38
            'options' => $this->options,
39
        ]);
40
        echo "</section>";
41
    }
42
}