1 | <?php |
||
37 | 1 | abstract class ConfirmerAttributes extends BaseControl |
|
38 | { |
||
39 | /** |
||
40 | * @var array localization strings |
||
41 | */ |
||
42 | public static $strings = [ |
||
43 | 'yes' => 'Yes', |
||
44 | 'no' => 'No', |
||
45 | 'expired' => 'Confirmation token has expired. Please try action again.', |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $cssClass; |
||
52 | |||
53 | /** |
||
54 | * @var string|callable heading |
||
55 | */ |
||
56 | protected $heading; |
||
57 | |||
58 | /** |
||
59 | * @var string|callable question |
||
60 | */ |
||
61 | protected $question; |
||
62 | |||
63 | /** |
||
64 | * @var string|callable icon |
||
65 | */ |
||
66 | protected $icon; |
||
67 | |||
68 | /** |
||
69 | * @var callable |
||
70 | */ |
||
71 | protected $handler; |
||
72 | |||
73 | /** |
||
74 | * @var bool |
||
75 | */ |
||
76 | protected $useAjax = TRUE; |
||
77 | |||
78 | /** |
||
79 | * @var Storage\IStorage |
||
80 | */ |
||
81 | protected $storage; |
||
82 | |||
83 | /** |
||
84 | * @param Storage\IStorage $storage |
||
85 | */ |
||
86 | public function __construct(Storage\IStorage $storage) |
||
95 | |||
96 | /** |
||
97 | * Set dialog heading |
||
98 | * |
||
99 | * @param string|callable $heading |
||
100 | * |
||
101 | * @return void |
||
102 | * |
||
103 | * @throws Exceptions\InvalidArgumentException |
||
104 | */ |
||
105 | public function setHeading($heading) |
||
113 | |||
114 | /** |
||
115 | * Get dialog heding |
||
116 | * |
||
117 | * @return string|NULL |
||
118 | * |
||
119 | * @throws Exceptions\InvalidStateException |
||
120 | */ |
||
121 | public function getHeading() |
||
125 | |||
126 | /** |
||
127 | * Set dialog question |
||
128 | * |
||
129 | * @param string|callable $question |
||
130 | * |
||
131 | * @return void |
||
132 | * |
||
133 | * @throws Exceptions\InvalidArgumentException |
||
134 | */ |
||
135 | public function setQuestion($question) |
||
143 | |||
144 | /** |
||
145 | * @return string|bool |
||
146 | * |
||
147 | * @throws Exceptions\InvalidStateException |
||
148 | */ |
||
149 | public function getQuestion() |
||
167 | |||
168 | /** |
||
169 | * Set dialog icon |
||
170 | * |
||
171 | * @param string|callable $icon |
||
172 | * |
||
173 | * @return void |
||
174 | * |
||
175 | * @throws Exceptions\InvalidArgumentException |
||
176 | */ |
||
177 | public function setIcon($icon) |
||
185 | |||
186 | /** |
||
187 | * @return string|NULL |
||
188 | * |
||
189 | * @throws Exceptions\InvalidStateException |
||
190 | */ |
||
191 | public function getIcon() |
||
195 | |||
196 | /** |
||
197 | * Set dialog handler |
||
198 | * |
||
199 | * @param callable $handler |
||
200 | * |
||
201 | * @return void |
||
202 | * |
||
203 | * @throws Exceptions\InvalidArgumentException |
||
204 | */ |
||
205 | public function setHandler($handler) |
||
214 | |||
215 | /** |
||
216 | * @return callable |
||
217 | */ |
||
218 | public function getHandler() : callable |
||
222 | |||
223 | /** |
||
224 | * @param Nette\ComponentModel\IContainer $obj |
||
225 | * @param array $params |
||
226 | * |
||
227 | * @return mixed |
||
228 | * |
||
229 | * @throws Exceptions\HandlerNotCallableException |
||
230 | */ |
||
231 | public function callHandler(Nette\ComponentModel\IContainer $obj, array $params) |
||
251 | |||
252 | /** |
||
253 | * @return void |
||
254 | */ |
||
255 | public function enableAjax() |
||
259 | |||
260 | /** |
||
261 | * @return void |
||
262 | */ |
||
263 | public function disableAjax() |
||
267 | |||
268 | /** |
||
269 | * @return Application\UI\Form |
||
270 | */ |
||
271 | protected function createComponentForm() |
||
291 | |||
292 | /** |
||
293 | * @param string $token |
||
294 | * |
||
295 | * @return array |
||
296 | * |
||
297 | * @throws Exceptions\InvalidStateException |
||
298 | */ |
||
299 | protected function getConfirmerValues(string $token) : array |
||
311 | |||
312 | /** |
||
313 | * @param callable|string $var |
||
314 | * |
||
315 | * @return bool |
||
316 | * |
||
317 | * @throws Exceptions\InvalidArgumentException |
||
318 | */ |
||
319 | private function checkCallableOrString($var) : bool |
||
327 | |||
328 | /** |
||
329 | * @param callable $attribute |
||
330 | * |
||
331 | * @return string |
||
332 | * |
||
333 | * @throws Exceptions\InvalidStateException |
||
334 | */ |
||
335 | private function callCallableAttribute($attribute) : string |
||
349 | |||
350 | /** |
||
351 | * @param string $attribute |
||
352 | * |
||
353 | * @return string|NULL |
||
354 | * @throws Exceptions\InvalidStateException |
||
355 | */ |
||
356 | private function getAttribute(string $attribute) |
||
368 | } |
||
369 |