Completed
Push — master ( 8644ac...22e2b7 )
by Andrii
14:53
created

BulkOperation::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
/**
3
 * Server module for HiPanel.
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-core
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\widgets;
12
13
use hipanel\widgets\ModalButton;
14
use Yii;
15
use yii\base\Widget;
16
use yii\helpers\Html;
17
use yii\helpers\ArrayHelper;
18
19
20
class BulkOperation extends Widget
21
{
22
    /**
23
     * @var ActiveRecord
24
     */
25
    public $model;
26
27
    /**
28
     * @var ActiveRecords
29
     */
30
    public $models;
31
32
    /**
33
     * @var string
34
     */
35
    public $scenario;
36
37
    /**
38
     * @var array
39
     */
40
    public $hiddenInputs = [];
41
42
    /**
43
     * @var array
44
     */
45
    public $visibleInputs = [];
46
47
    /**
48
     * @var array
49
     */
50
    public $dropDownInputs = [];
51
52
    /**
53
     * @var string
54
     */
55
    public $headerTitle;
56
57
    /**
58
     * @var string
59
     */
60
    public $bodyWarning;
61
62
    /**
63
     * @var string
64
     */
65
    public $submitButton;
66
    public $submitButtonOptions;
67
68
    /**
69
     * @var string
70
     */
71
    public $affectedObjects;
72
73
    public function init()
74
    {
75
        parent::init();
76
77
        if ($this->model === null) {
78
            throw new InvalidConfigException('Please specify the "model" property.');
79
        }
80
81
        if ($this->models === null) {
82
            throw new InvalidConfigException('Please specify the "models" property.');
83
        }
84
85
        if ($this->scenario === null) {
86
            throw new InvalidConfigException('Please specify the "scenario" property.');
87
        }
88
89
        if ($this->affectedObjects === null) {
90
            throw new InvalidConfigException('Please specify the "affectedObjects" property.');
91
        }
92
93
        if ($this->hiddenInputs === null) {
94
            $this->hiddenInputs = [];
95
        }
96
97
        if ($this->dropDownInputs === null) {
98
            $this->dropDownInputs = [];
99
        }
100
101
        if ($this->visibleInputs === null) {
102
            $this->visibleInputs = [];
103
        }
104
105
    }
106
107
    public function run()
108
    {
109
        echo $this->render('bulk-operation', [
110
            'model' => $this->model,
111
            'models' => $this->models,
112
            'scenario' => $this->scenario,
113
            'bodyWarning' => $this->bodyWarning,
114
            'hiddenInputs' => $this->hiddenInputs,
115
            'visibleInputs' => $this->visibleInputs,
116
            'dropDownInputs' => $this->dropDownInputs,
117
            'submitButton' => $this->submitButton,
118
            'submitButtonOptions' => $this->submitButtonOptions,
119
            'affectedObjects' => $this->affectedObjects,
120
        ]);
121
    }
122
}
123