Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like DataGrid often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DataGrid, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
32 | 1 | class DataGrid extends Nette\Application\UI\Control |
|
33 | { |
||
34 | 1 | use TDataGridAggregationFunction; |
|
35 | |||
36 | /** |
||
37 | * @var callable[] |
||
38 | */ |
||
39 | public $onRedraw; |
||
40 | |||
41 | /** |
||
42 | * @var callable[] |
||
43 | */ |
||
44 | public $onRender = []; |
||
45 | |||
46 | /** |
||
47 | * @var callable[] |
||
48 | */ |
||
49 | public $onExport; |
||
50 | |||
51 | /** |
||
52 | * @var callable[] |
||
53 | */ |
||
54 | public $onColumnAdd; |
||
55 | |||
56 | /** |
||
57 | * @var callable[] |
||
58 | * @deprecated use $onFiltersAssembled |
||
59 | */ |
||
60 | public $onFiltersAssabled; |
||
61 | |||
62 | /** |
||
63 | * @var callable[] |
||
64 | */ |
||
65 | public $onFiltersAssembled; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | */ |
||
70 | public static $icon_prefix = 'fa fa-'; |
||
71 | |||
72 | /** |
||
73 | * Default form method |
||
74 | * @var string |
||
75 | */ |
||
76 | public static $form_method = 'post'; |
||
77 | |||
78 | /** |
||
79 | * When set to TRUE, datagrid throws an exception |
||
80 | * when tring to get related entity within join and entity does not exist |
||
81 | * @var bool |
||
82 | */ |
||
83 | public $strict_entity_property = false; |
||
84 | |||
85 | /** |
||
86 | * When set to TRUE, datagrid throws an exception |
||
87 | * when tring to set filter value, that does not exist (select, multiselect, etc) |
||
88 | * @var bool |
||
89 | */ |
||
90 | public $strict_session_filter_values = true; |
||
91 | |||
92 | /** |
||
93 | * @var int |
||
94 | * @persistent |
||
95 | */ |
||
96 | public $page = 1; |
||
97 | |||
98 | /** |
||
99 | * @var int|string |
||
100 | * @persistent |
||
101 | */ |
||
102 | public $per_page; |
||
103 | |||
104 | /** |
||
105 | * @var array |
||
106 | * @persistent |
||
107 | */ |
||
108 | public $sort = []; |
||
109 | |||
110 | /** |
||
111 | * @var array |
||
112 | */ |
||
113 | public $default_sort = []; |
||
114 | |||
115 | /** |
||
116 | * @var array |
||
117 | */ |
||
118 | public $default_filter = []; |
||
119 | |||
120 | /** |
||
121 | * @var bool |
||
122 | */ |
||
123 | public $default_filter_use_on_reset = true; |
||
124 | |||
125 | /** |
||
126 | * @var bool |
||
127 | */ |
||
128 | public $default_sort_use_on_reset = true; |
||
129 | |||
130 | /** |
||
131 | * @var array |
||
132 | * @persistent |
||
133 | */ |
||
134 | public $filter = []; |
||
135 | |||
136 | /** |
||
137 | * @var callable|null |
||
138 | */ |
||
139 | protected $sort_callback = null; |
||
140 | |||
141 | /** |
||
142 | * @var bool |
||
143 | */ |
||
144 | protected $use_happy_components = true; |
||
145 | |||
146 | /** |
||
147 | * @var callable |
||
148 | */ |
||
149 | protected $rowCallback; |
||
150 | |||
151 | /** |
||
152 | * @var array |
||
153 | */ |
||
154 | protected $items_per_page_list; |
||
155 | |||
156 | /** |
||
157 | * @var int |
||
158 | */ |
||
159 | protected $default_per_page; |
||
160 | |||
161 | /** |
||
162 | * @var string |
||
163 | */ |
||
164 | protected $template_file; |
||
165 | |||
166 | /** |
||
167 | * @var Column\IColumn[] |
||
168 | */ |
||
169 | protected $columns = []; |
||
170 | |||
171 | /** |
||
172 | * @var Column\Action[] |
||
173 | */ |
||
174 | protected $actions = []; |
||
175 | |||
176 | /** |
||
177 | * @var GroupAction\GroupActionCollection |
||
178 | */ |
||
179 | protected $group_action_collection; |
||
180 | |||
181 | /** |
||
182 | * @var Filter\Filter[] |
||
183 | */ |
||
184 | protected $filters = []; |
||
185 | |||
186 | /** |
||
187 | * @var Export\Export[] |
||
188 | */ |
||
189 | protected $exports = []; |
||
190 | |||
191 | /** |
||
192 | * @var ToolbarButton[] |
||
193 | */ |
||
194 | protected $toolbar_buttons = []; |
||
195 | |||
196 | /** |
||
197 | * @var DataModel |
||
198 | */ |
||
199 | protected $dataModel; |
||
200 | |||
201 | /** |
||
202 | * @var DataFilter |
||
203 | */ |
||
204 | protected $dataFilter; |
||
205 | |||
206 | /** |
||
207 | * @var string |
||
208 | */ |
||
209 | protected $primary_key = 'id'; |
||
210 | |||
211 | /** |
||
212 | * @var bool |
||
213 | */ |
||
214 | protected $do_paginate = true; |
||
215 | |||
216 | /** |
||
217 | * @var bool |
||
218 | */ |
||
219 | protected $csv_export = true; |
||
220 | |||
221 | /** |
||
222 | * @var bool |
||
223 | */ |
||
224 | protected $csv_export_filtered = true; |
||
225 | |||
226 | /** |
||
227 | * @var bool |
||
228 | */ |
||
229 | protected $sortable = false; |
||
230 | |||
231 | /** |
||
232 | * @var bool |
||
233 | */ |
||
234 | protected $multiSort = false; |
||
235 | |||
236 | /** |
||
237 | * @var string |
||
238 | */ |
||
239 | protected $sortable_handler = 'sort!'; |
||
240 | |||
241 | /** |
||
242 | * @var string |
||
243 | */ |
||
244 | protected $original_template; |
||
245 | |||
246 | /** |
||
247 | * @var array |
||
248 | */ |
||
249 | protected $redraw_item; |
||
250 | |||
251 | /** |
||
252 | * @var mixed |
||
253 | */ |
||
254 | protected $translator; |
||
255 | |||
256 | /** |
||
257 | * @var bool |
||
258 | */ |
||
259 | protected $force_filter_active; |
||
260 | |||
261 | /** |
||
262 | * @var callable |
||
263 | */ |
||
264 | protected $tree_view_children_callback; |
||
265 | |||
266 | /** |
||
267 | * @var callable |
||
268 | */ |
||
269 | protected $tree_view_has_children_callback; |
||
270 | |||
271 | /** |
||
272 | * @var string |
||
273 | */ |
||
274 | protected $tree_view_has_children_column; |
||
275 | |||
276 | /** |
||
277 | * @var bool |
||
278 | */ |
||
279 | protected $outer_filter_rendering = false; |
||
280 | |||
281 | /** |
||
282 | * @var int |
||
283 | */ |
||
284 | protected $outer_filter_columns_count = 2; |
||
285 | |||
286 | /** |
||
287 | * @var bool |
||
288 | */ |
||
289 | protected $collapsible_outer_filters = true; |
||
290 | |||
291 | /** |
||
292 | * @var array |
||
293 | */ |
||
294 | protected $columns_export_order = []; |
||
295 | |||
296 | /** |
||
297 | * @var bool |
||
298 | */ |
||
299 | protected $remember_state = true; |
||
300 | |||
301 | /** |
||
302 | * @var bool |
||
303 | */ |
||
304 | protected $refresh_url = true; |
||
305 | |||
306 | /** |
||
307 | * @var Nette\Http\SessionSection |
||
308 | */ |
||
309 | protected $grid_session; |
||
310 | |||
311 | /** |
||
312 | * @var Column\ItemDetail |
||
313 | */ |
||
314 | protected $items_detail; |
||
315 | |||
316 | /** |
||
317 | * @var array |
||
318 | */ |
||
319 | protected $row_conditions = [ |
||
320 | 'group_action' => false, |
||
321 | 'action' => [], |
||
322 | ]; |
||
323 | |||
324 | /** |
||
325 | * @var array |
||
326 | */ |
||
327 | protected $column_callbacks = []; |
||
328 | |||
329 | /** |
||
330 | * @var bool |
||
331 | */ |
||
332 | protected $can_hide_columns = false; |
||
333 | |||
334 | /** |
||
335 | * @var array |
||
336 | */ |
||
337 | protected $columns_visibility = []; |
||
338 | |||
339 | /** |
||
340 | * @var InlineEdit |
||
341 | */ |
||
342 | protected $inlineEdit; |
||
343 | |||
344 | /** |
||
345 | * @var InlineEdit |
||
346 | */ |
||
347 | protected $inlineAdd; |
||
348 | |||
349 | /** |
||
350 | * @var bool |
||
351 | */ |
||
352 | protected $snippets_set = false; |
||
353 | |||
354 | /** |
||
355 | * @var bool |
||
356 | */ |
||
357 | protected $some_column_default_hide = false; |
||
358 | |||
359 | /** |
||
360 | * @var ColumnsSummary |
||
361 | */ |
||
362 | protected $columnsSummary; |
||
363 | |||
364 | /** |
||
365 | * @var bool |
||
366 | */ |
||
367 | protected $auto_submit = true; |
||
368 | |||
369 | /** |
||
370 | * @var Filter\SubmitButton|NULL |
||
371 | */ |
||
372 | protected $filter_submit_button = null; |
||
373 | |||
374 | /** |
||
375 | * @var bool |
||
376 | */ |
||
377 | protected $has_column_reset = true; |
||
378 | |||
379 | /** |
||
380 | * @var bool |
||
381 | */ |
||
382 | protected $show_selected_rows_count = true; |
||
383 | |||
384 | |||
385 | /** |
||
386 | * @param Nette\ComponentModel\IContainer|NULL $parent |
||
387 | * @param string $name |
||
388 | */ |
||
389 | public function __construct(Nette\ComponentModel\IContainer $parent = null, $name = null) |
||
427 | |||
428 | |||
429 | /** |
||
430 | * {inheritDoc} |
||
431 | * @return void |
||
432 | */ |
||
433 | public function attached($presenter) |
||
446 | |||
447 | |||
448 | /******************************************************************************** |
||
449 | * RENDERING * |
||
450 | ********************************************************************************/ |
||
451 | |||
452 | |||
453 | /** |
||
454 | * Render template |
||
455 | * @return void |
||
456 | */ |
||
457 | public function render() |
||
562 | |||
563 | |||
564 | /******************************************************************************** |
||
565 | * ROW CALLBACK * |
||
566 | ********************************************************************************/ |
||
567 | |||
568 | |||
569 | /** |
||
570 | * Each row can be modified with user callback |
||
571 | * @param callable $callback |
||
572 | * @return static |
||
573 | */ |
||
574 | public function setRowCallback(callable $callback) |
||
580 | |||
581 | |||
582 | /******************************************************************************** |
||
583 | * DATA SOURCE * |
||
584 | ********************************************************************************/ |
||
585 | |||
586 | |||
587 | /** |
||
588 | * By default ID, you can change that |
||
589 | * @param string $primary_key |
||
590 | * @return static |
||
591 | */ |
||
592 | public function setPrimaryKey($primary_key) |
||
602 | |||
603 | |||
604 | /** |
||
605 | * Set Grid data source |
||
606 | * @param DataSource\IDataSource|array|\Dibi\Fluent|Nette\Database\Table\Selection|\Doctrine\ORM\QueryBuilder $source |
||
607 | * @return static |
||
608 | */ |
||
609 | public function setDataSource($source) |
||
619 | |||
620 | |||
621 | /** |
||
622 | * @return DataSource\IDataSource|NULL |
||
623 | */ |
||
624 | public function getDataSource() |
||
632 | |||
633 | |||
634 | /******************************************************************************** |
||
635 | * TEMPLATING * |
||
636 | ********************************************************************************/ |
||
637 | |||
638 | |||
639 | /** |
||
640 | * Set custom template file to render |
||
641 | * @param string $template_file |
||
642 | * @return static |
||
643 | */ |
||
644 | public function setTemplateFile($template_file) |
||
650 | |||
651 | |||
652 | /** |
||
653 | * Get DataGrid template file |
||
654 | * @return string |
||
655 | * @return static |
||
656 | */ |
||
657 | public function getTemplateFile() |
||
661 | |||
662 | |||
663 | /** |
||
664 | * Get DataGrid original template file |
||
665 | * @return string |
||
666 | */ |
||
667 | public function getOriginalTemplateFile() |
||
671 | |||
672 | |||
673 | /** |
||
674 | * Tell datagrid wheteher to use or not happy components |
||
675 | * @param bool|NULL $use If not given, return value of static::$use_happy_components |
||
676 | * @return void|bool |
||
677 | */ |
||
678 | public function useHappyComponents($use = null) |
||
686 | |||
687 | |||
688 | /******************************************************************************** |
||
689 | * SORTING * |
||
690 | ********************************************************************************/ |
||
691 | |||
692 | |||
693 | /** |
||
694 | * Set default sorting |
||
695 | * @param array $sort |
||
696 | * @param bool $use_on_reset |
||
697 | * @return static |
||
698 | */ |
||
699 | public function setDefaultSort($sort, $use_on_reset = true) |
||
712 | |||
713 | |||
714 | /** |
||
715 | * Return default sort for column, if specified |
||
716 | * @param string $columnKey |
||
717 | * @return string|NULL |
||
718 | */ |
||
719 | public function getColumnDefaultSort($columnKey) |
||
727 | |||
728 | |||
729 | /** |
||
730 | * User may set default sorting, apply it |
||
731 | * @return void |
||
732 | */ |
||
733 | public function findDefaultSort() |
||
749 | |||
750 | |||
751 | /** |
||
752 | * Set grido to be sortable |
||
753 | * @param bool $sortable |
||
754 | * @return static |
||
755 | */ |
||
756 | public function setSortable($sortable = true) |
||
766 | |||
767 | |||
768 | /** |
||
769 | * Tell whether DataGrid is sortable |
||
770 | * @return bool |
||
771 | */ |
||
772 | public function isSortable() |
||
776 | |||
777 | |||
778 | /** |
||
779 | * Enable multi-sorting capability |
||
780 | * @param bool $multiSort |
||
781 | * @return static |
||
782 | */ |
||
783 | public function setMultiSortEnabled($multiSort = true) |
||
789 | |||
790 | |||
791 | /** |
||
792 | * Tell wether DataGrid can be sorted by multiple columns |
||
793 | * @return bool |
||
794 | */ |
||
795 | public function isMultiSortEnabled() |
||
799 | |||
800 | |||
801 | /** |
||
802 | * Set sortable handle |
||
803 | * @param string $handler |
||
804 | * @return static |
||
805 | */ |
||
806 | public function setSortableHandler($handler = 'sort!') |
||
812 | |||
813 | |||
814 | /** |
||
815 | * Return sortable handle name |
||
816 | * @return string |
||
817 | */ |
||
818 | public function getSortableHandler() |
||
822 | |||
823 | |||
824 | /** |
||
825 | * @param Column $column |
||
826 | * @return array |
||
827 | * @internal |
||
828 | */ |
||
829 | public function getSortNext(\Ublaboo\DataGrid\Column\Column $column) |
||
839 | |||
840 | |||
841 | /** |
||
842 | * @param array $sort |
||
843 | * @param callable|NULL $sort_callback |
||
844 | * @return Sorting |
||
845 | */ |
||
846 | protected function createSorting(array $sort, callable $sort_callback = null) |
||
867 | |||
868 | |||
869 | /******************************************************************************** |
||
870 | * TREE VIEW * |
||
871 | ********************************************************************************/ |
||
872 | |||
873 | |||
874 | /** |
||
875 | * Is tree view set? |
||
876 | * @return bool |
||
877 | */ |
||
878 | public function isTreeView() |
||
882 | |||
883 | |||
884 | /** |
||
885 | * Setting tree view |
||
886 | * @param callable $get_children_callback |
||
887 | * @param string|callable $tree_view_has_children_column |
||
888 | * @return static |
||
889 | */ |
||
890 | public function setTreeView($get_children_callback, $tree_view_has_children_column = 'has_children') |
||
920 | |||
921 | |||
922 | /** |
||
923 | * Is tree view children callback set? |
||
924 | * @return bool |
||
925 | */ |
||
926 | public function hasTreeViewChildrenCallback() |
||
930 | |||
931 | |||
932 | /** |
||
933 | * @param mixed $item |
||
934 | * @return bool |
||
935 | */ |
||
936 | public function treeViewChildrenCallback($item) |
||
940 | |||
941 | |||
942 | /******************************************************************************** |
||
943 | * COLUMNS * |
||
944 | ********************************************************************************/ |
||
945 | |||
946 | |||
947 | /** |
||
948 | * Add text column with no other formating |
||
949 | * @param string $key |
||
950 | * @param string $name |
||
951 | * @param string|null $column |
||
952 | * @return Column\ColumnText |
||
953 | */ |
||
954 | public function addColumnText($key, $name, $column = null) |
||
961 | |||
962 | |||
963 | /** |
||
964 | * Add column with link |
||
965 | * @param string $key |
||
966 | * @param string $name |
||
967 | * @param string|null $column |
||
968 | * @return Column\ColumnLink |
||
969 | */ |
||
970 | public function addColumnLink($key, $name, $href = null, $column = null, array $params = null) |
||
982 | |||
983 | |||
984 | /** |
||
985 | * Add column with possible number formating |
||
986 | * @param string $key |
||
987 | * @param string $name |
||
988 | * @param string|null $column |
||
989 | * @return Column\ColumnNumber |
||
990 | */ |
||
991 | public function addColumnNumber($key, $name, $column = null) |
||
998 | |||
999 | |||
1000 | /** |
||
1001 | * Add column with date formating |
||
1002 | * @param string $key |
||
1003 | * @param string $name |
||
1004 | * @param string|null $column |
||
1005 | * @return Column\ColumnDateTime |
||
1006 | */ |
||
1007 | public function addColumnDateTime($key, $name, $column = null) |
||
1014 | |||
1015 | |||
1016 | /** |
||
1017 | * Add column status |
||
1018 | * @param string $key |
||
1019 | * @param string $name |
||
1020 | * @param string|null $column |
||
1021 | * @return Column\ColumnStatus |
||
1022 | */ |
||
1023 | public function addColumnStatus($key, $name, $column = null) |
||
1030 | |||
1031 | |||
1032 | /** |
||
1033 | * @param string $key |
||
1034 | * @param Column\Column $column |
||
1035 | * @return Column\Column |
||
1036 | */ |
||
1037 | protected function addColumn($key, Column\Column $column) |
||
1047 | |||
1048 | |||
1049 | /** |
||
1050 | * Return existing column |
||
1051 | * @param string $key |
||
1052 | * @return Column\Column |
||
1053 | * @throws DataGridException |
||
1054 | */ |
||
1055 | public function getColumn($key) |
||
1063 | |||
1064 | |||
1065 | /** |
||
1066 | * Remove column |
||
1067 | * @param string $key |
||
1068 | * @return static |
||
1069 | */ |
||
1070 | public function removeColumn($key) |
||
1077 | |||
1078 | |||
1079 | /** |
||
1080 | * Check whether given key already exists in $this->columns |
||
1081 | * @param string $key |
||
1082 | * @throws DataGridException |
||
1083 | */ |
||
1084 | protected function addColumnCheck($key) |
||
1090 | |||
1091 | |||
1092 | /******************************************************************************** |
||
1093 | * ACTIONS * |
||
1094 | ********************************************************************************/ |
||
1095 | |||
1096 | |||
1097 | /** |
||
1098 | * Create action |
||
1099 | * @param string $key |
||
1100 | * @param string $name |
||
1101 | * @param string $href |
||
1102 | * @param array|null $params |
||
1103 | * @return Column\Action |
||
1104 | */ |
||
1105 | public function addAction($key, $name, $href = null, array $params = null) |
||
1117 | |||
1118 | |||
1119 | /** |
||
1120 | * Create action callback |
||
1121 | * @param string $key |
||
1122 | * @param string $name |
||
1123 | * @return Column\Action |
||
1124 | */ |
||
1125 | public function addActionCallback($key, $name, $callback = null) |
||
1143 | |||
1144 | |||
1145 | /** |
||
1146 | * @param string $key |
||
1147 | */ |
||
1148 | public function addMultiAction($key, $name) |
||
1156 | |||
1157 | |||
1158 | /** |
||
1159 | * Get existing action |
||
1160 | * @param string $key |
||
1161 | * @return Column\Action |
||
1162 | * @throws DataGridException |
||
1163 | */ |
||
1164 | View Code Duplication | public function getAction($key) |
|
1172 | |||
1173 | |||
1174 | /** |
||
1175 | * Remove action |
||
1176 | * @param string $key |
||
1177 | * @return static |
||
1178 | */ |
||
1179 | public function removeAction($key) |
||
1185 | |||
1186 | |||
1187 | /** |
||
1188 | * Check whether given key already exists in $this->filters |
||
1189 | * @param string $key |
||
1190 | * @throws DataGridException |
||
1191 | */ |
||
1192 | protected function addActionCheck($key) |
||
1198 | |||
1199 | |||
1200 | /******************************************************************************** |
||
1201 | * FILTERS * |
||
1202 | ********************************************************************************/ |
||
1203 | |||
1204 | |||
1205 | /** |
||
1206 | * Add filter fot text search |
||
1207 | * @param string $key |
||
1208 | * @param string $name |
||
1209 | * @param array|string $columns |
||
1210 | * @return Filter\FilterText |
||
1211 | * @throws DataGridException |
||
1212 | */ |
||
1213 | public function addFilterText($key, $name, $columns = null) |
||
1225 | |||
1226 | |||
1227 | /** |
||
1228 | * Add select box filter |
||
1229 | * @param string $key |
||
1230 | * @param string $name |
||
1231 | * @param array $options |
||
1232 | * @param string $column |
||
1233 | * @return Filter\FilterSelect |
||
1234 | * @throws DataGridException |
||
1235 | */ |
||
1236 | View Code Duplication | public function addFilterSelect($key, $name, array $options, $column = null) |
|
1248 | |||
1249 | |||
1250 | /** |
||
1251 | * Add multi select box filter |
||
1252 | * @param string $key |
||
1253 | * @param string $name |
||
1254 | * @param array $options |
||
1255 | * @param string $column |
||
1256 | * @return Filter\FilterSelect |
||
1257 | * @throws DataGridException |
||
1258 | */ |
||
1259 | View Code Duplication | public function addFilterMultiSelect($key, $name, array $options, $column = null) |
|
1271 | |||
1272 | |||
1273 | /** |
||
1274 | * Add datepicker filter |
||
1275 | * @param string $key |
||
1276 | * @param string $name |
||
1277 | * @param string $column |
||
1278 | * @return Filter\FilterDate |
||
1279 | * @throws DataGridException |
||
1280 | */ |
||
1281 | View Code Duplication | public function addFilterDate($key, $name, $column = null) |
|
1293 | |||
1294 | |||
1295 | /** |
||
1296 | * Add range filter (from - to) |
||
1297 | * @param string $key |
||
1298 | * @param string $name |
||
1299 | * @param string $column |
||
1300 | * @return Filter\FilterRange |
||
1301 | * @throws DataGridException |
||
1302 | */ |
||
1303 | View Code Duplication | public function addFilterRange($key, $name, $column = null, $name_second = '-') |
|
1315 | |||
1316 | |||
1317 | /** |
||
1318 | * Add datepicker filter (from - to) |
||
1319 | * @param string $key |
||
1320 | * @param string $name |
||
1321 | * @param string $column |
||
1322 | * @return Filter\FilterDateRange |
||
1323 | * @throws DataGridException |
||
1324 | */ |
||
1325 | View Code Duplication | public function addFilterDateRange($key, $name, $column = null, $name_second = '-') |
|
1337 | |||
1338 | |||
1339 | /** |
||
1340 | * Check whether given key already exists in $this->filters |
||
1341 | * @param string $key |
||
1342 | * @throws DataGridException |
||
1343 | */ |
||
1344 | protected function addFilterCheck($key) |
||
1350 | |||
1351 | |||
1352 | /** |
||
1353 | * Fill array of Filter\Filter[] with values from $this->filter persistent parameter |
||
1354 | * Fill array of Column\Column[] with values from $this->sort persistent parameter |
||
1355 | * @return Filter\Filter[] $this->filters === Filter\Filter[] |
||
1356 | */ |
||
1357 | public function assembleFilters() |
||
1394 | |||
1395 | |||
1396 | /** |
||
1397 | * Fill array of Filter\Filter[] with values from $this->filter persistent parameter |
||
1398 | * Fill array of Column\Column[] with values from $this->sort persistent parameter |
||
1399 | * @return Filter\Filter[] $this->filters === Filter\Filter[] |
||
1400 | * @deprecated use assembleFilters instead |
||
1401 | */ |
||
1402 | public function assableFilters() |
||
1407 | |||
1408 | |||
1409 | /** |
||
1410 | * Remove filter |
||
1411 | * @param string $key |
||
1412 | * @return static |
||
1413 | */ |
||
1414 | public function removeFilter($key) |
||
1420 | |||
1421 | |||
1422 | /** |
||
1423 | * Get defined filter |
||
1424 | * @param string $key |
||
1425 | * @return Filter\Filter |
||
1426 | */ |
||
1427 | public function getFilter($key) |
||
1435 | |||
1436 | |||
1437 | /** |
||
1438 | * @param bool $strict |
||
1439 | * @return static |
||
1440 | */ |
||
1441 | public function setStrictSessionFilterValues($strict = true) |
||
1447 | |||
1448 | |||
1449 | /******************************************************************************** |
||
1450 | * FILTERING * |
||
1451 | ********************************************************************************/ |
||
1452 | |||
1453 | |||
1454 | /** |
||
1455 | * Is filter active? |
||
1456 | * @return bool |
||
1457 | */ |
||
1458 | public function isFilterActive() |
||
1464 | |||
1465 | |||
1466 | /** |
||
1467 | * Tell that filter is active from whatever reasons |
||
1468 | * return static |
||
1469 | */ |
||
1470 | public function setFilterActive() |
||
1476 | |||
1477 | |||
1478 | /** |
||
1479 | * Set filter values (force - overwrite user data) |
||
1480 | * @param array $filter |
||
1481 | * @return static |
||
1482 | */ |
||
1483 | public function setFilter(array $filter) |
||
1491 | |||
1492 | |||
1493 | /** |
||
1494 | * If we want to sent some initial filter |
||
1495 | * @param array $filter |
||
1496 | * @param bool $use_on_reset |
||
1497 | * @return static |
||
1498 | */ |
||
1499 | public function setDefaultFilter(array $default_filter, $use_on_reset = true) |
||
1537 | |||
1538 | |||
1539 | /** |
||
1540 | * User may set default filter, find it |
||
1541 | * @return void |
||
1542 | */ |
||
1543 | public function findDefaultFilter() |
||
1561 | |||
1562 | |||
1563 | /** |
||
1564 | * FilterAndGroupAction form factory |
||
1565 | * @return Form |
||
1566 | */ |
||
1567 | public function createComponentFilter() |
||
1656 | |||
1657 | |||
1658 | /** |
||
1659 | * @param Nette\Forms\Container $container |
||
1660 | * @param array|\Iterator $values |
||
1661 | * @return void |
||
1662 | */ |
||
1663 | public function setFilterContainerDefaults(Nette\Forms\Container $container, $values) |
||
1692 | |||
1693 | |||
1694 | /** |
||
1695 | * Set $this->filter values after filter form submitted |
||
1696 | * @param Form $form |
||
1697 | * @return void |
||
1698 | */ |
||
1699 | public function filterSucceeded(Form $form) |
||
1814 | |||
1815 | |||
1816 | /** |
||
1817 | * Should be datagrid filters rendered separately? |
||
1818 | * @param bool $out |
||
1819 | * @return static |
||
1820 | */ |
||
1821 | public function setOuterFilterRendering($out = true) |
||
1827 | |||
1828 | |||
1829 | /** |
||
1830 | * Are datagrid filters rendered separately? |
||
1831 | * @return bool |
||
1832 | */ |
||
1833 | public function hasOuterFilterRendering() |
||
1837 | |||
1838 | |||
1839 | /** |
||
1840 | * Set the number of columns in the outer filter |
||
1841 | * @param int $count |
||
1842 | * @return static |
||
1843 | * @throws \InvalidArgumentException |
||
1844 | */ |
||
1845 | public function setOuterFilterColumnsCount($count) |
||
1857 | |||
1858 | |||
1859 | /** |
||
1860 | * @return bool |
||
1861 | */ |
||
1862 | public function getOuterFilterColumnsCount() |
||
1866 | |||
1867 | |||
1868 | /** |
||
1869 | * @param bool $collapsible_outer_filters |
||
1870 | */ |
||
1871 | public function setCollapsibleOuterFilters($collapsible_outer_filters = true) |
||
1875 | |||
1876 | |||
1877 | /** |
||
1878 | * @return bool |
||
1879 | */ |
||
1880 | public function hasCollapsibleOuterFilters() |
||
1884 | |||
1885 | |||
1886 | /** |
||
1887 | * Try to restore session stuff |
||
1888 | * @return void |
||
1889 | * @throws DataGridFilterNotFoundException |
||
1890 | */ |
||
1891 | public function findSessionValues() |
||
1959 | |||
1960 | |||
1961 | /******************************************************************************** |
||
1962 | * EXPORTS * |
||
1963 | ********************************************************************************/ |
||
1964 | |||
1965 | |||
1966 | /** |
||
1967 | * Add export of type callback |
||
1968 | * @param string $text |
||
1969 | * @param callable $callback |
||
1970 | * @param bool $filtered |
||
1971 | * @return Export\Export |
||
1972 | */ |
||
1973 | public function addExportCallback($text, $callback, $filtered = false) |
||
1981 | |||
1982 | |||
1983 | /** |
||
1984 | * Add already implemented csv export |
||
1985 | * @param string $text |
||
1986 | * @param string $csv_file_name |
||
1987 | * @param string|null $output_encoding |
||
1988 | * @param string|null $delimiter |
||
1989 | * @param bool $include_bom |
||
1990 | * @return Export\Export |
||
1991 | */ |
||
1992 | View Code Duplication | public function addExportCsv( |
|
2009 | |||
2010 | |||
2011 | /** |
||
2012 | * Add already implemented csv export, but for filtered data |
||
2013 | * @param string $text |
||
2014 | * @param string $csv_file_name |
||
2015 | * @param string|null $output_encoding |
||
2016 | * @param string|null $delimiter |
||
2017 | * @param bool $include_bom |
||
2018 | * @return Export\Export |
||
2019 | */ |
||
2020 | View Code Duplication | public function addExportCsvFiltered( |
|
2037 | |||
2038 | |||
2039 | /** |
||
2040 | * Add export to array |
||
2041 | * @param Export\Export $export |
||
2042 | * @return Export\Export |
||
2043 | */ |
||
2044 | protected function addToExports(Export\Export $export) |
||
2052 | |||
2053 | |||
2054 | /** |
||
2055 | * @return void |
||
2056 | */ |
||
2057 | public function resetExportsLinks() |
||
2063 | |||
2064 | |||
2065 | /******************************************************************************** |
||
2066 | * TOOLBAR BUTTONS * |
||
2067 | ********************************************************************************/ |
||
2068 | |||
2069 | |||
2070 | /** |
||
2071 | * Add toolbar button |
||
2072 | * @param string $href |
||
2073 | * @param string $text |
||
2074 | * @param array $params |
||
2075 | * @return ToolbarButton |
||
2076 | * @throws DataGridException |
||
2077 | */ |
||
2078 | public function addToolbarButton($href, $text = '', $params = []) |
||
2086 | |||
2087 | |||
2088 | /** |
||
2089 | * Get existing toolbar button |
||
2090 | * @param string $key |
||
2091 | * @return ToolbarButton |
||
2092 | * @throws DataGridException |
||
2093 | */ |
||
2094 | public function getToolbarButton($key) |
||
2102 | |||
2103 | |||
2104 | /** |
||
2105 | * Remove toolbar button. |
||
2106 | * @param string $key |
||
2107 | * @return static |
||
2108 | */ |
||
2109 | public function removeToolbarButton($key) |
||
2115 | |||
2116 | |||
2117 | /******************************************************************************** |
||
2118 | * GROUP ACTIONS * |
||
2119 | ********************************************************************************/ |
||
2120 | |||
2121 | |||
2122 | /** |
||
2123 | * Alias for add group select action |
||
2124 | * @param string $title |
||
2125 | * @param array $options |
||
2126 | * @return GroupAction\GroupAction |
||
2127 | */ |
||
2128 | public function addGroupAction($title, $options = []) |
||
2132 | |||
2133 | |||
2134 | /** |
||
2135 | * Add group action (select box) |
||
2136 | * @param string $title |
||
2137 | * @param array $options |
||
2138 | * @return GroupAction\GroupAction |
||
2139 | */ |
||
2140 | public function addGroupSelectAction($title, $options = []) |
||
2144 | |||
2145 | |||
2146 | /** |
||
2147 | * Add group action (multiselect box) |
||
2148 | * @param string $title |
||
2149 | * @param array $options |
||
2150 | * @return GroupAction\GroupAction |
||
2151 | */ |
||
2152 | public function addGroupMultiSelectAction($title, $options = []) |
||
2156 | |||
2157 | |||
2158 | /** |
||
2159 | * Add group action (text input) |
||
2160 | * @param string $title |
||
2161 | * @return GroupAction\GroupAction |
||
2162 | */ |
||
2163 | public function addGroupTextAction($title) |
||
2167 | |||
2168 | |||
2169 | /** |
||
2170 | * Add group action (textarea) |
||
2171 | * @param string $title |
||
2172 | * @return GroupAction\GroupAction |
||
2173 | */ |
||
2174 | public function addGroupTextareaAction($title) |
||
2178 | |||
2179 | |||
2180 | /** |
||
2181 | * Get collection of all group actions |
||
2182 | * @return GroupAction\GroupActionCollection |
||
2183 | */ |
||
2184 | public function getGroupActionCollection() |
||
2192 | |||
2193 | |||
2194 | /** |
||
2195 | * Has datagrid some group actions? |
||
2196 | * @return bool |
||
2197 | */ |
||
2198 | public function hasGroupActions() |
||
2202 | |||
2203 | |||
2204 | /** |
||
2205 | * @return bool |
||
2206 | */ |
||
2207 | public function shouldShowSelectedRowsCount() |
||
2211 | |||
2212 | |||
2213 | /** |
||
2214 | * @return static |
||
2215 | */ |
||
2216 | public function setShowSelectedRowsCount($show = true) |
||
2222 | |||
2223 | |||
2224 | /******************************************************************************** |
||
2225 | * HANDLERS * |
||
2226 | ********************************************************************************/ |
||
2227 | |||
2228 | |||
2229 | /** |
||
2230 | * Handler for changind page (just refresh site with page as persistent paramter set) |
||
2231 | * @param int $page |
||
2232 | * @return void |
||
2233 | */ |
||
2234 | public function handlePage($page) |
||
2244 | |||
2245 | |||
2246 | /** |
||
2247 | * Handler for sorting |
||
2248 | * @param array $sort |
||
2249 | * @return void |
||
2250 | * @throws DataGridColumnNotFoundException |
||
2251 | */ |
||
2252 | public function handleSort(array $sort) |
||
2277 | |||
2278 | |||
2279 | /** |
||
2280 | * Handler for reseting the filter |
||
2281 | * @return void |
||
2282 | */ |
||
2283 | public function handleResetFilter() |
||
2316 | |||
2317 | |||
2318 | /** |
||
2319 | * @param string $key |
||
2320 | * @return void |
||
2321 | */ |
||
2322 | public function handleResetColumnFilter($key) |
||
2329 | |||
2330 | |||
2331 | /** |
||
2332 | * @param bool $reset |
||
2333 | * @return static |
||
2334 | */ |
||
2335 | public function setColumnReset($reset = true) |
||
2341 | |||
2342 | |||
2343 | /** |
||
2344 | * @return bool |
||
2345 | */ |
||
2346 | public function hasColumnReset() |
||
2350 | |||
2351 | |||
2352 | /** |
||
2353 | * @param Filter\Filter[] $filters |
||
2354 | * @return void |
||
2355 | */ |
||
2356 | public function sendNonEmptyFiltersInPayload($filters) |
||
2372 | |||
2373 | |||
2374 | /** |
||
2375 | * Handler for export |
||
2376 | * @param int $id Key for particular export class in array $this->exports |
||
2377 | * @return void |
||
2378 | */ |
||
2379 | public function handleExport($id) |
||
2432 | |||
2433 | |||
2434 | /** |
||
2435 | * Handler for getting children of parent item (e.g. category) |
||
2436 | * @param int $parent |
||
2437 | * @return void |
||
2438 | */ |
||
2439 | View Code Duplication | public function handleGetChildren($parent) |
|
2456 | |||
2457 | |||
2458 | /** |
||
2459 | * Handler for getting item detail |
||
2460 | * @param mixed $id |
||
2461 | * @return void |
||
2462 | */ |
||
2463 | public function handleGetItemDetail($id) |
||
2484 | |||
2485 | |||
2486 | /** |
||
2487 | * Handler for inline editing |
||
2488 | * @param mixed $id |
||
2489 | * @param mixed $key |
||
2490 | * @return void |
||
2491 | */ |
||
2492 | public function handleEdit($id, $key) |
||
2504 | |||
2505 | |||
2506 | /** |
||
2507 | * Redraw $this |
||
2508 | * @return void |
||
2509 | */ |
||
2510 | public function reload($snippets = []) |
||
2536 | |||
2537 | |||
2538 | /** |
||
2539 | * @return void |
||
2540 | */ |
||
2541 | View Code Duplication | public function reloadTheWholeGrid() |
|
2554 | |||
2555 | |||
2556 | /** |
||
2557 | * Handler for column status |
||
2558 | * @param string $id |
||
2559 | * @param string $key |
||
2560 | * @param string $value |
||
2561 | * @return void |
||
2562 | */ |
||
2563 | public function handleChangeStatus($id, $key, $value) |
||
2571 | |||
2572 | |||
2573 | /** |
||
2574 | * Redraw just one row via ajax |
||
2575 | * @param int $id |
||
2576 | * @param mixed $primary_where_column |
||
2577 | * @return void |
||
2578 | */ |
||
2579 | public function redrawItem($id, $primary_where_column = null) |
||
2591 | |||
2592 | |||
2593 | /** |
||
2594 | * Tell datagrid to display all columns |
||
2595 | * @return void |
||
2596 | */ |
||
2597 | public function handleShowAllColumns() |
||
2606 | |||
2607 | |||
2608 | /** |
||
2609 | * Tell datagrid to display default columns |
||
2610 | * @return void |
||
2611 | */ |
||
2612 | public function handleShowDefaultColumns() |
||
2621 | |||
2622 | |||
2623 | /** |
||
2624 | * Reveal particular column |
||
2625 | * @param string $column |
||
2626 | * @return void |
||
2627 | */ |
||
2628 | View Code Duplication | public function handleShowColumn($column) |
|
2647 | |||
2648 | |||
2649 | /** |
||
2650 | * Notice datagrid to not display particular columns |
||
2651 | * @param string $column |
||
2652 | * @return void |
||
2653 | */ |
||
2654 | View Code Duplication | public function handleHideColumn($column) |
|
2674 | |||
2675 | |||
2676 | public function handleActionCallback($__key, $__id) |
||
2686 | |||
2687 | |||
2688 | /******************************************************************************** |
||
2689 | * PAGINATION * |
||
2690 | ********************************************************************************/ |
||
2691 | |||
2692 | |||
2693 | /** |
||
2694 | * Set options of select "items_per_page" |
||
2695 | * @param array $items_per_page_list |
||
2696 | * @return static |
||
2697 | */ |
||
2698 | public function setItemsPerPageList(array $items_per_page_list, $include_all = true) |
||
2708 | |||
2709 | |||
2710 | /** |
||
2711 | * Set default "items per page" value in pagination select |
||
2712 | * @param $count |
||
2713 | * @return static |
||
2714 | */ |
||
2715 | public function setDefaultPerPage($count) |
||
2721 | |||
2722 | |||
2723 | /** |
||
2724 | * User may set default "items per page" value, apply it |
||
2725 | * @return void |
||
2726 | */ |
||
2727 | public function findDefaultPerPage() |
||
2739 | |||
2740 | |||
2741 | /** |
||
2742 | * Paginator factory |
||
2743 | * @return Components\DataGridPaginator\DataGridPaginator |
||
2744 | */ |
||
2745 | public function createComponentPaginator() |
||
2761 | |||
2762 | |||
2763 | /** |
||
2764 | * Get parameter per_page |
||
2765 | * @return int |
||
2766 | */ |
||
2767 | public function getPerPage() |
||
2779 | |||
2780 | |||
2781 | /** |
||
2782 | * Get associative array of items_per_page_list |
||
2783 | * @return array |
||
2784 | */ |
||
2785 | public function getItemsPerPageList() |
||
2803 | |||
2804 | |||
2805 | /** |
||
2806 | * Order Grid to "be paginated" |
||
2807 | * @param bool $do |
||
2808 | * @return static |
||
2809 | */ |
||
2810 | public function setPagination($do) |
||
2816 | |||
2817 | |||
2818 | /** |
||
2819 | * Tell whether Grid is paginated |
||
2820 | * @return bool |
||
2821 | */ |
||
2822 | public function isPaginated() |
||
2826 | |||
2827 | |||
2828 | /** |
||
2829 | * Return current paginator class |
||
2830 | * @return NULL|Components\DataGridPaginator\DataGridPaginator |
||
2831 | */ |
||
2832 | public function getPaginator() |
||
2840 | |||
2841 | |||
2842 | /******************************************************************************** |
||
2843 | * I18N * |
||
2844 | ********************************************************************************/ |
||
2845 | |||
2846 | |||
2847 | /** |
||
2848 | * Set datagrid translator |
||
2849 | * @param Nette\Localization\ITranslator $translator |
||
2850 | * @return static |
||
2851 | */ |
||
2852 | public function setTranslator(Nette\Localization\ITranslator $translator) |
||
2858 | |||
2859 | |||
2860 | /** |
||
2861 | * Get translator for datagrid |
||
2862 | * @return Nette\Localization\ITranslator |
||
2863 | */ |
||
2864 | public function getTranslator() |
||
2872 | |||
2873 | |||
2874 | /******************************************************************************** |
||
2875 | * COLUMNS ORDER * |
||
2876 | ********************************************************************************/ |
||
2877 | |||
2878 | |||
2879 | /** |
||
2880 | * Set order of datagrid columns |
||
2881 | * @param array $order |
||
2882 | * @return static |
||
2883 | */ |
||
2884 | public function setColumnsOrder($order) |
||
2902 | |||
2903 | |||
2904 | /** |
||
2905 | * Columns order may be different for export and normal grid |
||
2906 | * @param array $order |
||
2907 | */ |
||
2908 | public function setColumnsExportOrder($order) |
||
2912 | |||
2913 | |||
2914 | /******************************************************************************** |
||
2915 | * SESSION & URL * |
||
2916 | ********************************************************************************/ |
||
2917 | |||
2918 | |||
2919 | /** |
||
2920 | * Find some unique session key name |
||
2921 | * @return string |
||
2922 | */ |
||
2923 | public function getSessionSectionName() |
||
2927 | |||
2928 | |||
2929 | /** |
||
2930 | * Should datagrid remember its filters/pagination/etc using session? |
||
2931 | * @param bool $remember |
||
2932 | * @return static |
||
2933 | */ |
||
2934 | public function setRememberState($remember = true) |
||
2940 | |||
2941 | |||
2942 | /** |
||
2943 | * Should datagrid refresh url using history API? |
||
2944 | * @param bool $refresh |
||
2945 | * @return static |
||
2946 | */ |
||
2947 | public function setRefreshUrl($refresh = true) |
||
2954 | |||
2955 | |||
2956 | /** |
||
2957 | * Get session data if functionality is enabled |
||
2958 | * @param string $key |
||
2959 | * @return mixed |
||
2960 | */ |
||
2961 | public function getSessionData($key = null, $default_value = null) |
||
2969 | |||
2970 | |||
2971 | /** |
||
2972 | * Save session data - just if it is enabled |
||
2973 | * @param string $key |
||
2974 | * @param mixed $value |
||
2975 | * @return void |
||
2976 | */ |
||
2977 | public function saveSessionData($key, $value) |
||
2983 | |||
2984 | |||
2985 | /** |
||
2986 | * Delete session data |
||
2987 | * @return void |
||
2988 | */ |
||
2989 | public function deleteSessionData($key) |
||
2993 | |||
2994 | |||
2995 | /** |
||
2996 | * Delete session data |
||
2997 | * @return void |
||
2998 | * @deprecated |
||
2999 | */ |
||
3000 | public function deleteSesssionData($key) |
||
3005 | |||
3006 | |||
3007 | /******************************************************************************** |
||
3008 | * ITEM DETAIL * |
||
3009 | ********************************************************************************/ |
||
3010 | |||
3011 | |||
3012 | /** |
||
3013 | * Get items detail parameters |
||
3014 | * @return array |
||
3015 | */ |
||
3016 | public function getItemsDetail() |
||
3020 | |||
3021 | |||
3022 | /** |
||
3023 | * Items can have thair detail - toggled |
||
3024 | * @param mixed $detail callable|string|bool |
||
3025 | * @param bool|NULL $primary_where_column |
||
3026 | * @return Column\ItemDetail |
||
3027 | */ |
||
3028 | public function setItemsDetail($detail = true, $primary_where_column = null) |
||
3067 | |||
3068 | |||
3069 | /** |
||
3070 | * @param callable $callable_set_container |
||
3071 | * @return static |
||
3072 | */ |
||
3073 | public function setItemsDetailForm(callable $callable_set_container) |
||
3085 | |||
3086 | |||
3087 | /** |
||
3088 | * @return Nette\Forms\Container|NULL |
||
3089 | */ |
||
3090 | public function getItemDetailForm() |
||
3098 | |||
3099 | |||
3100 | /******************************************************************************** |
||
3101 | * ROW PRIVILEGES * |
||
3102 | ********************************************************************************/ |
||
3103 | |||
3104 | |||
3105 | /** |
||
3106 | * @param callable $condition |
||
3107 | * @return void |
||
3108 | */ |
||
3109 | public function allowRowsGroupAction(callable $condition) |
||
3113 | |||
3114 | |||
3115 | /** |
||
3116 | * @param callable $condition |
||
3117 | * @return void |
||
3118 | */ |
||
3119 | public function allowRowsInlineEdit(callable $condition) |
||
3123 | |||
3124 | |||
3125 | /** |
||
3126 | * @param string $key |
||
3127 | * @param callable $condition |
||
3128 | * @return void |
||
3129 | */ |
||
3130 | public function allowRowsAction($key, callable $condition) |
||
3134 | |||
3135 | |||
3136 | /** |
||
3137 | * @param string $multiActionKey |
||
3138 | * @param string $actionKey |
||
3139 | * @param callable $condition |
||
3140 | * @return void |
||
3141 | */ |
||
3142 | public function allowRowsMultiAction($multiActionKey, $actionKey, callable $condition) |
||
3154 | |||
3155 | |||
3156 | /** |
||
3157 | * @param string $name |
||
3158 | * @param string|null $key |
||
3159 | * @return bool|callable |
||
3160 | */ |
||
3161 | public function getRowCondition($name, $key = null) |
||
3175 | |||
3176 | |||
3177 | /******************************************************************************** |
||
3178 | * COLUMN CALLBACK * |
||
3179 | ********************************************************************************/ |
||
3180 | |||
3181 | |||
3182 | /** |
||
3183 | * @param string $key |
||
3184 | * @param callable $callback |
||
3185 | * @return void |
||
3186 | */ |
||
3187 | public function addColumnCallback($key, callable $callback) |
||
3191 | |||
3192 | |||
3193 | /** |
||
3194 | * @param string $key |
||
3195 | * @return callable|null |
||
3196 | */ |
||
3197 | public function getColumnCallback($key) |
||
3201 | |||
3202 | |||
3203 | /******************************************************************************** |
||
3204 | * INLINE EDIT * |
||
3205 | ********************************************************************************/ |
||
3206 | |||
3207 | |||
3208 | /** |
||
3209 | * @return InlineEdit |
||
3210 | */ |
||
3211 | public function addInlineEdit($primary_where_column = null) |
||
3217 | |||
3218 | |||
3219 | /** |
||
3220 | * @return InlineEdit|null |
||
3221 | */ |
||
3222 | public function getInlineEdit() |
||
3226 | |||
3227 | |||
3228 | /** |
||
3229 | * @param mixed $id |
||
3230 | * @return void |
||
3231 | */ |
||
3232 | public function handleInlineEdit($id) |
||
3250 | |||
3251 | |||
3252 | /******************************************************************************** |
||
3253 | * INLINE ADD * |
||
3254 | ********************************************************************************/ |
||
3255 | |||
3256 | |||
3257 | /** |
||
3258 | * @return InlineEdit |
||
3259 | */ |
||
3260 | public function addInlineAdd() |
||
3271 | |||
3272 | |||
3273 | /** |
||
3274 | * @return InlineEdit|null |
||
3275 | */ |
||
3276 | public function getInlineAdd() |
||
3280 | |||
3281 | |||
3282 | /******************************************************************************** |
||
3283 | * HIDEABLE COLUMNS * |
||
3284 | ********************************************************************************/ |
||
3285 | |||
3286 | |||
3287 | /** |
||
3288 | * Can datagrid hide colums? |
||
3289 | * @return bool |
||
3290 | */ |
||
3291 | public function canHideColumns() |
||
3295 | |||
3296 | |||
3297 | /** |
||
3298 | * Order Grid to set columns hideable. |
||
3299 | * @return static |
||
3300 | */ |
||
3301 | public function setColumnsHideable() |
||
3307 | |||
3308 | |||
3309 | /******************************************************************************** |
||
3310 | * COLUMNS SUMMARY * |
||
3311 | ********************************************************************************/ |
||
3312 | |||
3313 | |||
3314 | /** |
||
3315 | * Will datagrid show summary in the end? |
||
3316 | * @return bool |
||
3317 | */ |
||
3318 | public function hasColumnsSummary() |
||
3322 | |||
3323 | |||
3324 | /** |
||
3325 | * Set columns to be summarized in the end. |
||
3326 | * @param array $columns |
||
3327 | * @param callable $rowCallback |
||
3328 | * @return \Ublaboo\DataGrid\ColumnsSummary |
||
3329 | */ |
||
3330 | public function setColumnsSummary(array $columns, $rowCallback = null) |
||
3346 | |||
3347 | |||
3348 | /** |
||
3349 | * @return ColumnsSummary|NULL |
||
3350 | */ |
||
3351 | public function getColumnsSummary() |
||
3355 | |||
3356 | |||
3357 | /******************************************************************************** |
||
3358 | * INTERNAL * |
||
3359 | ********************************************************************************/ |
||
3360 | |||
3361 | |||
3362 | /** |
||
3363 | * Tell grid filters to by submitted automatically |
||
3364 | * @param bool $auto |
||
3365 | */ |
||
3366 | public function setAutoSubmit($auto = true) |
||
3372 | |||
3373 | |||
3374 | /** |
||
3375 | * @return bool |
||
3376 | */ |
||
3377 | public function hasAutoSubmit() |
||
3381 | |||
3382 | |||
3383 | /** |
||
3384 | * Submit button when no auto-submitting is used |
||
3385 | * @return Filter\SubmitButton |
||
3386 | */ |
||
3387 | public function getFilterSubmitButton() |
||
3401 | |||
3402 | |||
3403 | /******************************************************************************** |
||
3404 | * INTERNAL * |
||
3405 | ********************************************************************************/ |
||
3406 | |||
3407 | |||
3408 | /** |
||
3409 | * Get count of columns |
||
3410 | * @return int |
||
3411 | */ |
||
3412 | public function getColumnsCount() |
||
3430 | |||
3431 | |||
3432 | /** |
||
3433 | * Get primary key of datagrid data source |
||
3434 | * @return string |
||
3435 | */ |
||
3436 | public function getPrimaryKey() |
||
3440 | |||
3441 | |||
3442 | /** |
||
3443 | * Get set of set columns |
||
3444 | * @return Column\IColumn[] |
||
3445 | */ |
||
3446 | public function getColumns() |
||
3485 | |||
3486 | |||
3487 | public function getColumnsVisibility() |
||
3497 | |||
3498 | |||
3499 | /** |
||
3500 | * @return PresenterComponent |
||
3501 | */ |
||
3502 | public function getParent() |
||
3514 | |||
3515 | |||
3516 | /** |
||
3517 | * @return string |
||
3518 | */ |
||
3519 | public function getSortableParentPath() |
||
3523 | |||
3524 | |||
3525 | /** |
||
3526 | * Some of datagrid columns is hidden by default |
||
3527 | * @param bool $default_hide |
||
3528 | */ |
||
3529 | public function setSomeColumnDefaultHide($default_hide) |
||
3533 | |||
3534 | |||
3535 | /** |
||
3536 | * Are some of columns hidden bydefault? |
||
3537 | */ |
||
3538 | public function hasSomeColumnDefaultHide() |
||
3542 | |||
3543 | |||
3544 | /** |
||
3545 | * Simply refresh url |
||
3546 | * @return void |
||
3547 | */ |
||
3548 | public function handleRefreshState() |
||
3558 | } |
||
3559 | |||
3560 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.