Completed
Push — master ( ff2b0b...f369f8 )
by Alexey
05:58
created

SubscribeForm::init()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 1
nop 0
1
<?php
2
3
4
namespace common\components\maintenance\widgets;
5
6
use yii\base\Widget;
7
use common\components\maintenance\models\SubscribeForm as SubscribeFormModel;
8
use common\components\maintenance\widgets\assets\SubscribeFormAsset;
9
10
/**
11
 * Class SubscribeForm
12
 * @package common\components\maintenance\widgets
13
 */
14
class SubscribeForm extends Widget
15
{
16
    /**
17
     * @var bool
18
     */
19
    public $status = true;
20
21
    /**
22
     * @var SubscribeFormModel
23
     */
24
    public $model;
25
26
    public function init()
27
    {
28
        parent::init();
29
        $this->model = $this->model ?: new SubscribeFormModel();
30
    }
31
32
    /**
33
     * @return string|void
34
     */
35
    public function run()
36
    {
37
        if ($this->status === true) {
38
            $this->registerResource();
39
            echo $this->render('subscribe-form', ['model' => $this->model]);
40
        }
41
    }
42
43
    /**
44
     * Register resource
45
     */
46
    protected function registerResource()
47
    {
48
        $view = $this->getView();
49
        SubscribeFormAsset::register($view);
50
    }
51
}
52