1 | <?php |
||
19 | class Action extends Column |
||
20 | { |
||
21 | |||
22 | use Traits\TButton; |
||
23 | use Traits\TLink; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | public static $data_confirm_attribute_name = 'datagrid-confirm'; |
||
29 | |||
30 | /** |
||
31 | * @var DataGrid |
||
32 | */ |
||
33 | protected $grid; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $href; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $name; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $params; |
||
49 | |||
50 | /** |
||
51 | * @var array|callable |
||
52 | */ |
||
53 | protected $confirm; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $data_attributes = []; |
||
59 | |||
60 | /** |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $attributes = []; |
||
64 | |||
65 | |||
66 | /** |
||
67 | * @param DataGrid $grid |
||
68 | * @param string $href |
||
69 | * @param string $name |
||
70 | * @param array $params |
||
71 | */ |
||
72 | public function __construct(DataGrid $grid, $href, $name, $params) |
||
79 | |||
80 | |||
81 | /** |
||
82 | * Render row item into template |
||
83 | * @param Row $row |
||
84 | * @return mixed |
||
85 | */ |
||
86 | public function render(Row $row) |
||
135 | |||
136 | |||
137 | /** |
||
138 | * Set attribute title |
||
139 | * @param string|callable $title |
||
140 | * @return static |
||
141 | * @throws DataGridException |
||
142 | */ |
||
143 | public function setTitle($title) |
||
151 | |||
152 | |||
153 | /** |
||
154 | * Get attribute title |
||
155 | * @param Row $row |
||
156 | * @return string |
||
157 | * @throws DataGridException |
||
158 | */ |
||
159 | public function getTitle(Row $row) |
||
166 | |||
167 | |||
168 | /** |
||
169 | * Set attribute class |
||
170 | * @param string|callable $class |
||
171 | * @return static |
||
172 | * @throws DataGridException |
||
173 | */ |
||
174 | public function setClass($class) |
||
182 | |||
183 | |||
184 | /** |
||
185 | * Get attribute class |
||
186 | * @param Row $row |
||
187 | * @return string |
||
188 | * @throws DataGridException |
||
189 | */ |
||
190 | public function getClass(Row $row) |
||
197 | |||
198 | |||
199 | /** |
||
200 | * Set icon |
||
201 | * @param string|callable $icon |
||
202 | * @return static|callable |
||
203 | * @throws DataGridException |
||
204 | */ |
||
205 | public function setIcon($icon) |
||
213 | |||
214 | |||
215 | /** |
||
216 | * Get icon |
||
217 | * @param Row $row |
||
218 | * @return string |
||
219 | * @throws DataGridException |
||
220 | */ |
||
221 | public function getIcon(Row $row) |
||
228 | |||
229 | |||
230 | /** |
||
231 | * Set confirm dialog |
||
232 | * @param string|callable $message |
||
233 | * @param string $column |
||
234 | * @return static |
||
235 | * @throws DataGridException |
||
236 | */ |
||
237 | public function setConfirm($message, $column = NULL) |
||
245 | |||
246 | |||
247 | /** |
||
248 | * Get confirm dialog for particular row item |
||
249 | * @param Row $row |
||
250 | * @return string |
||
251 | * @throws DataGridException |
||
252 | */ |
||
253 | public function getConfirm(Row $row) |
||
276 | |||
277 | |||
278 | /** |
||
279 | * Setting data attributes |
||
280 | * @param string $key |
||
281 | * @param mixed $value |
||
282 | * @return static |
||
283 | */ |
||
284 | public function setDataAttribute($key, $value) |
||
290 | |||
291 | |||
292 | /** |
||
293 | * Set attributes for a element |
||
294 | * @param array $attrs |
||
295 | * @return static |
||
296 | */ |
||
297 | public function addAttributes(array $attrs) |
||
303 | |||
304 | |||
305 | /** |
||
306 | * Check whether given property is string or callable |
||
307 | * @param mixed $property |
||
308 | * @return void |
||
309 | * @throws DataGridException |
||
310 | */ |
||
311 | protected function checkPropertyStringOrCallable($property, $name) |
||
319 | |||
320 | |||
321 | /** |
||
322 | * Check whether given property is string or callable |
||
323 | * in that case call callback and check property and return it |
||
324 | * @param Row $row |
||
325 | * @param string|callable|null $property |
||
326 | * @param string $name |
||
327 | * @return string |
||
328 | * @throws DataGridException |
||
329 | */ |
||
330 | public function getPropertyStringOrCallableGetString(Row $row, $property, $name) |
||
354 | |||
355 | |||
356 | /** |
||
357 | * Translator helper |
||
358 | * @param string $message |
||
359 | * @return string |
||
360 | */ |
||
361 | protected function translate($message) |
||
365 | |||
366 | } |
||
367 |