1 | <?php |
||
36 | class Widget extends BaseWidget |
||
37 | { |
||
38 | /** Name of inline JavaScript package that is registered by the widget */ |
||
39 | const INLINE_JS_KEY = 'vova07/imperavi/'; |
||
40 | |||
41 | /** |
||
42 | * @var Model|null The data model that this widget is associated with. |
||
43 | */ |
||
44 | public $model; |
||
45 | |||
46 | /** |
||
47 | * @var string|null The model attribute that this widget is associated with. |
||
48 | */ |
||
49 | public $attribute; |
||
50 | |||
51 | /** |
||
52 | * @var string|null The input name. This must be set if `model` and `attribute` are not set. |
||
53 | */ |
||
54 | public $name; |
||
55 | |||
56 | /** |
||
57 | * @var string|null The input value. |
||
58 | */ |
||
59 | public $value; |
||
60 | |||
61 | /** |
||
62 | * @var string|null Selector pointing to textarea to initialize redactor for. |
||
63 | * Defaults to `null` meaning that textarea does not exist yet and will be rendered by this widget. |
||
64 | */ |
||
65 | public $selector; |
||
66 | |||
67 | /** |
||
68 | * @var array The HTML attribute options for the input tag. |
||
69 | * |
||
70 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
71 | */ |
||
72 | public $options = []; |
||
73 | |||
74 | /** |
||
75 | * @var array {@link https://imperavi.com/assets/pdf/redactor-documentation-10.pdf redactor options} to manage the redactor itself. |
||
76 | */ |
||
77 | public $settings = []; |
||
78 | |||
79 | /** |
||
80 | * @var array Default settings that will be merged with {@link $settings}. Useful with DI container. |
||
81 | */ |
||
82 | public $defaultSettings = []; |
||
83 | |||
84 | /** |
||
85 | * This property must be used only for registering widget's custom plugins. |
||
86 | * The `key` is the name of the plugin, and the `value` must be the class name of the plugin bundle. |
||
87 | * |
||
88 | * @var array Widget custom plugins ['key' => 'value'] array. |
||
89 | * |
||
90 | * @example `['my-custom-plugin' => MyCustomPlugin::className(), ...]` |
||
91 | */ |
||
92 | public $plugins = []; |
||
93 | |||
94 | /** |
||
95 | * @var boolean Whether to render the `textarea` or not. |
||
96 | */ |
||
97 | private $_renderTextarea = true; |
||
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | 42 | public function init() |
|
136 | |||
137 | /** |
||
138 | * @inheritdoc |
||
139 | */ |
||
140 | 18 | public function run() |
|
154 | |||
155 | /** |
||
156 | * Register widget translations. |
||
157 | */ |
||
158 | 45 | public static function registerTranslations() |
|
171 | |||
172 | /** |
||
173 | * @return boolean whether this widget is associated with a data model. |
||
174 | */ |
||
175 | 42 | protected function hasModel() |
|
179 | |||
180 | /** |
||
181 | * Register all widget logic. |
||
182 | */ |
||
183 | 18 | protected function register() |
|
189 | |||
190 | /** |
||
191 | * Register default callbacks. |
||
192 | */ |
||
193 | 21 | protected function registerDefaultCallbacks() |
|
206 | |||
207 | /** |
||
208 | * Register widget asset. |
||
209 | */ |
||
210 | 24 | protected function registerClientScripts() |
|
236 | } |
||
237 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: