1 | <?php |
||
35 | 1 | abstract class ConfirmerAttributes extends BaseControl |
|
36 | { |
||
37 | /** |
||
38 | * @var array localization strings |
||
39 | */ |
||
40 | public static $strings = [ |
||
41 | 'yes' => 'Yes', |
||
42 | 'no' => 'No', |
||
43 | 'expired' => 'Confirmation token has expired. Please try action again.', |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $cssClass; |
||
50 | |||
51 | /** |
||
52 | * @var string|callable heading |
||
53 | */ |
||
54 | protected $heading; |
||
55 | |||
56 | /** |
||
57 | * @var string|callable question |
||
58 | */ |
||
59 | protected $question; |
||
60 | |||
61 | /** |
||
62 | * @var string|callable icon |
||
63 | */ |
||
64 | protected $icon; |
||
65 | |||
66 | /** |
||
67 | * @var callable |
||
68 | */ |
||
69 | protected $handler; |
||
70 | |||
71 | /** |
||
72 | * @var bool |
||
73 | */ |
||
74 | protected $useAjax = TRUE; |
||
75 | |||
76 | /** |
||
77 | * @var Storage\IStorage |
||
78 | */ |
||
79 | protected $storage; |
||
80 | |||
81 | /** |
||
82 | * @param Storage\IStorage $storage |
||
83 | */ |
||
84 | public function __construct(Storage\IStorage $storage) |
||
93 | |||
94 | /** |
||
95 | * Set dialog heading |
||
96 | * |
||
97 | * @param string|callable $heading |
||
98 | * |
||
99 | * @return void |
||
100 | * |
||
101 | * @throws Exceptions\InvalidArgumentException |
||
102 | */ |
||
103 | public function setHeading($heading) : void |
||
111 | |||
112 | /** |
||
113 | * Get dialog heding |
||
114 | * |
||
115 | * @return string|NULL |
||
116 | * |
||
117 | * @throws Exceptions\InvalidStateException |
||
118 | */ |
||
119 | public function getHeading() : ?string |
||
123 | |||
124 | /** |
||
125 | * Set dialog question |
||
126 | * |
||
127 | * @param string|callable $question |
||
128 | * |
||
129 | * @return void |
||
130 | * |
||
131 | * @throws Exceptions\InvalidArgumentException |
||
132 | */ |
||
133 | public function setQuestion($question) : void |
||
141 | |||
142 | /** |
||
143 | * @return string|NULL |
||
144 | * |
||
145 | * @throws Exceptions\InvalidStateException |
||
146 | */ |
||
147 | public function getQuestion() : ?string |
||
165 | |||
166 | /** |
||
167 | * Set dialog icon |
||
168 | * |
||
169 | * @param string|callable $icon |
||
170 | * |
||
171 | * @return void |
||
172 | * |
||
173 | * @throws Exceptions\InvalidArgumentException |
||
174 | */ |
||
175 | public function setIcon($icon) : void |
||
183 | |||
184 | /** |
||
185 | * @return string|NULL |
||
186 | * |
||
187 | * @throws Exceptions\InvalidStateException |
||
188 | */ |
||
189 | public function getIcon() : ?string |
||
193 | |||
194 | /** |
||
195 | * Set dialog handler |
||
196 | * |
||
197 | * @param callable $handler |
||
198 | * |
||
199 | * @return void |
||
200 | */ |
||
201 | public function setHandler(callable $handler) : void |
||
206 | |||
207 | /** |
||
208 | * @return callable |
||
209 | */ |
||
210 | public function getHandler() : callable |
||
214 | |||
215 | /** |
||
216 | * @param ComponentModel\IContainer $obj |
||
217 | * @param array $params |
||
218 | * |
||
219 | * @return mixed |
||
220 | * |
||
221 | * @throws Exceptions\HandlerNotCallableException |
||
222 | */ |
||
223 | public function callHandler(ComponentModel\IContainer $obj, array $params) |
||
243 | |||
244 | /** |
||
245 | * @return void |
||
246 | */ |
||
247 | public function enableAjax() : void |
||
251 | |||
252 | /** |
||
253 | * @return void |
||
254 | */ |
||
255 | public function disableAjax() : void |
||
259 | |||
260 | /** |
||
261 | * @return Application\UI\Form |
||
262 | */ |
||
263 | protected function createComponentForm() : Application\UI\Form |
||
283 | |||
284 | /** |
||
285 | * @param string $token |
||
286 | * |
||
287 | * @return array |
||
288 | * |
||
289 | * @throws Exceptions\InvalidStateException |
||
290 | */ |
||
291 | protected function getConfirmerValues(string $token) : array |
||
303 | |||
304 | /** |
||
305 | * @param callable|string $var |
||
306 | * |
||
307 | * @return bool |
||
308 | * |
||
309 | * @throws Exceptions\InvalidArgumentException |
||
310 | */ |
||
311 | private function checkCallableOrString($var) : bool |
||
319 | |||
320 | /** |
||
321 | * @param callable $attribute |
||
322 | * |
||
323 | * @return string |
||
324 | * |
||
325 | * @throws Exceptions\InvalidStateException |
||
326 | */ |
||
327 | private function callCallableAttribute(callable $attribute) : string |
||
341 | |||
342 | /** |
||
343 | * @param string $attribute |
||
344 | * |
||
345 | * @return string|NULL |
||
346 | * |
||
347 | * @throws Exceptions\InvalidStateException |
||
348 | */ |
||
349 | private function getAttribute(string $attribute) : ?string |
||
361 | } |
||
362 |