1 | <?php |
||
19 | class Action extends Column |
||
20 | { |
||
21 | |||
22 | use Traits\ButtonIconTrait; |
||
23 | |||
24 | /** |
||
25 | * @var string|callable |
||
26 | */ |
||
27 | protected $title; |
||
28 | |||
29 | /** |
||
30 | * @var string|callable |
||
31 | */ |
||
32 | protected $class; |
||
33 | |||
34 | /** |
||
35 | * @var string|callable |
||
36 | */ |
||
37 | protected $icon; |
||
38 | |||
39 | /** |
||
40 | * @var DataGrid |
||
41 | */ |
||
42 | protected $grid; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $href; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $name; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $params; |
||
58 | |||
59 | /** |
||
60 | * @var array|callable |
||
61 | */ |
||
62 | protected $confirm; |
||
63 | |||
64 | /** |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $data_attributes = []; |
||
68 | |||
69 | |||
70 | /** |
||
71 | * @param DataGrid $grid |
||
72 | * @param string $href |
||
73 | * @param string $name |
||
74 | * @param array $params |
||
75 | */ |
||
76 | public function __construct(DataGrid $grid, $href, $name, $params) |
||
85 | |||
86 | |||
87 | /** |
||
88 | * Render row item into template |
||
89 | * @param Row $row |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function render(Row $row) |
||
121 | |||
122 | |||
123 | /** |
||
124 | * Set attribute title |
||
125 | * @param string|callable $title |
||
126 | * @return static |
||
127 | * @throws DataGridException |
||
128 | */ |
||
129 | public function setTitle($title) |
||
137 | |||
138 | |||
139 | /** |
||
140 | * Get attribute title |
||
141 | * @param Row $row |
||
142 | * @return string |
||
143 | * @throws DataGridException |
||
144 | */ |
||
145 | public function getTitle(Row $row) |
||
152 | |||
153 | |||
154 | /** |
||
155 | * Set attribute class |
||
156 | * @param string|callable $class |
||
157 | * @return static |
||
158 | * @throws DataGridException |
||
159 | */ |
||
160 | public function setClass($class) |
||
168 | |||
169 | |||
170 | /** |
||
171 | * Get attribute class |
||
172 | * @param Row $row |
||
173 | * @return string |
||
174 | * @throws DataGridException |
||
175 | */ |
||
176 | public function getClass(Row $row) |
||
183 | |||
184 | |||
185 | /** |
||
186 | * Set icon |
||
187 | * @param string|callable $icon |
||
188 | * @return static|callable |
||
189 | * @throws DataGridException |
||
190 | */ |
||
191 | public function setIcon($icon) |
||
199 | |||
200 | |||
201 | /** |
||
202 | * Get icon |
||
203 | * @param Row $row |
||
204 | * @return string |
||
205 | * @throws DataGridException |
||
206 | */ |
||
207 | public function getIcon(Row $row) |
||
214 | |||
215 | |||
216 | /** |
||
217 | * Set confirm dialog |
||
218 | * @param string|callable $message |
||
219 | * @param string $column |
||
220 | * @return static |
||
221 | * @throws DataGridException |
||
222 | */ |
||
223 | public function setConfirm($message, $column = NULL) |
||
231 | |||
232 | |||
233 | /** |
||
234 | * Get confirm dialog for particular row item |
||
235 | * @param Row $row |
||
236 | * @return string |
||
237 | * @throws DataGridException |
||
238 | */ |
||
239 | public function getConfirm(Row $row) |
||
258 | |||
259 | |||
260 | /** |
||
261 | * Setting data attributes |
||
262 | * @param string $key |
||
263 | * @param mixed $value |
||
264 | */ |
||
265 | public function setDataAttribute($key, $value) |
||
269 | |||
270 | |||
271 | /** |
||
272 | * Check whether given property is string or callable |
||
273 | * @param mixed $property |
||
274 | * @return void |
||
275 | * @throws DataGridException |
||
276 | */ |
||
277 | protected function checkPropertyStringOrCallable($property, $name) |
||
285 | |||
286 | |||
287 | /** |
||
288 | * Check whether given property is string or callable |
||
289 | * in that case call callback and check property and return it |
||
290 | * @param Row $row |
||
291 | * @param string|NULL $property |
||
292 | * @param string $name |
||
293 | * @return string |
||
294 | * @throws DataGridException |
||
295 | */ |
||
296 | public function getPropertyStringOrCallableGetString(Row $row, $property, $name) |
||
310 | |||
311 | |||
312 | /** |
||
313 | * Translator helper |
||
314 | * @param string $message |
||
315 | * @return string |
||
316 | */ |
||
317 | protected function translate($message) |
||
321 | |||
322 | } |
||
323 |