1 | <?php |
||
19 | class ItemDetail |
||
20 | { |
||
21 | |||
22 | use Traits\TButton; |
||
23 | |||
24 | /** |
||
25 | * (renderer | template | block) |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $type; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $template; |
||
34 | |||
35 | /** |
||
36 | * @var callable |
||
37 | */ |
||
38 | protected $renderer; |
||
39 | |||
40 | /** |
||
41 | * @var DataGrid |
||
42 | */ |
||
43 | protected $grid; |
||
44 | |||
45 | /** |
||
46 | * @var string|bool |
||
47 | */ |
||
48 | protected $primary_where_column; |
||
49 | |||
50 | /** |
||
51 | * @var ItemDetailForm |
||
52 | */ |
||
53 | protected $form; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $template_parameters = []; |
||
59 | |||
60 | /** |
||
61 | * @var callable |
||
62 | */ |
||
63 | protected $render_condition_callback; |
||
64 | |||
65 | |||
66 | /** |
||
67 | * @param DataGrid $grid |
||
68 | * @param string $primary_where_column |
||
69 | */ |
||
70 | public function __construct(DataGrid $grid, $primary_where_column) |
||
79 | |||
80 | |||
81 | /** |
||
82 | * Render row item detail button |
||
83 | * @param Row $row |
||
84 | * @return Html |
||
85 | */ |
||
86 | public function renderButton($row) |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Render item detail |
||
111 | * @param mixed $item |
||
112 | * @return mixed |
||
113 | */ |
||
114 | public function render($item) |
||
124 | |||
125 | |||
126 | /** |
||
127 | * Get primary column for where clause |
||
128 | * @return string|bool |
||
129 | */ |
||
130 | public function getPrimaryWhereColumn() |
||
134 | |||
135 | |||
136 | /** |
||
137 | * Set item detail type |
||
138 | * @param string $type |
||
139 | */ |
||
140 | public function setType($type) |
||
146 | |||
147 | |||
148 | /** |
||
149 | * Get item detail type |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getType() |
||
156 | |||
157 | |||
158 | /** |
||
159 | * Set item detail template |
||
160 | * @param string $template |
||
161 | */ |
||
162 | public function setTemplate($template) |
||
168 | |||
169 | |||
170 | /** |
||
171 | * Get item detail template |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getTemplate() |
||
178 | |||
179 | |||
180 | /** |
||
181 | * Set item detail renderer |
||
182 | * @param callable $renderer |
||
183 | */ |
||
184 | public function setRenderer($renderer) |
||
190 | |||
191 | |||
192 | /** |
||
193 | * Get item detail renderer |
||
194 | * @return callable |
||
195 | */ |
||
196 | public function getRenderer() |
||
200 | |||
201 | |||
202 | /** |
||
203 | * @param ItemDetailForm $form |
||
204 | * @return static |
||
205 | */ |
||
206 | public function setForm(ItemDetailForm $form) |
||
212 | |||
213 | |||
214 | /** |
||
215 | * @return ItemDetailForm |
||
216 | */ |
||
217 | public function getForm() |
||
221 | |||
222 | |||
223 | /** |
||
224 | * @param array $template_parameters |
||
225 | * @return static |
||
226 | */ |
||
227 | public function setTemplateParameters(array $template_parameters) |
||
233 | |||
234 | |||
235 | public function getTemplateVariables() |
||
239 | |||
240 | /** |
||
241 | * @param callable $condition |
||
242 | * @return static |
||
243 | */ |
||
244 | public function setRenderCondition(callable $condition) |
||
250 | |||
251 | /** |
||
252 | * @param Row $row |
||
253 | * @return bool |
||
254 | */ |
||
255 | public function shouldBeRendered(Row $row) |
||
261 | |||
262 | } |
||
263 |