1 | <?php |
||
13 | class GridConfig implements RegistryInterface |
||
14 | { |
||
15 | use TRegistry; |
||
16 | use TComponent; |
||
17 | |||
18 | const SECTION_DO_NOT_RENDER = 'not_render'; |
||
19 | |||
20 | protected $template = 'grids::default'; |
||
21 | |||
22 | /** @var FieldConfig[]|Collection */ |
||
23 | protected $columns; |
||
24 | |||
25 | /** @var DataProvider $data_provider */ |
||
26 | protected $data_provider; |
||
27 | |||
28 | protected $page_size = 50; |
||
29 | |||
30 | /** @var Collection|FilterConfig[] $filters */ |
||
31 | protected $filters; |
||
32 | |||
33 | /** @var int */ |
||
34 | protected $caching_time = 0; |
||
35 | |||
36 | protected $main_template = '*.grid'; |
||
37 | |||
38 | protected $row_component; |
||
39 | |||
40 | /** |
||
41 | * @return RenderableComponentInterface |
||
42 | */ |
||
43 | public function getRowComponent() |
||
55 | |||
56 | /** |
||
57 | * @param RenderableComponentInterface $rowComponent |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function setRowComponent(RenderableComponentInterface $rowComponent) |
||
67 | |||
68 | /** |
||
69 | * Returns default child components. |
||
70 | * |
||
71 | * |
||
72 | * @return \Illuminate\Support\Collection|Components\Base\ComponentInterface[]|array |
||
73 | */ |
||
74 | protected function getDefaultComponents() |
||
81 | |||
82 | /** |
||
83 | * @param string $template |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function setTemplate($template) |
||
91 | |||
92 | public function setMainTemplate($template) |
||
97 | |||
98 | public function getMainTemplate() |
||
102 | |||
103 | |||
104 | /** |
||
105 | * @param Collection|FilterConfig[] $filters |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function setFilters($filters) |
||
113 | |||
114 | public function getFilters() |
||
121 | |||
122 | /** |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getTemplate() |
||
129 | |||
130 | /** |
||
131 | * @param DataProvider $dataProvider |
||
132 | * @return $this |
||
133 | */ |
||
134 | public function setDataProvider(DataProvider $dataProvider) |
||
139 | |||
140 | /** |
||
141 | * @return DataProvider |
||
142 | */ |
||
143 | public function getDataProvider() |
||
147 | |||
148 | /** |
||
149 | * @param FieldConfig[]|Collection $columns |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function setColumns($columns) |
||
157 | |||
158 | /** |
||
159 | * Returns collection of grid columns. |
||
160 | * |
||
161 | * @return FieldConfig[]|Collection |
||
162 | */ |
||
163 | public function getColumns() |
||
170 | |||
171 | /** |
||
172 | * Returns column by name. |
||
173 | * |
||
174 | * @param string $name |
||
175 | * @return null|FieldConfig |
||
176 | */ |
||
177 | public function getColumn($name) |
||
186 | |||
187 | /** |
||
188 | * Returns cache expiration time in minutes. |
||
189 | * |
||
190 | * @return int |
||
191 | */ |
||
192 | public function getCachingTime() |
||
196 | |||
197 | /** |
||
198 | * Sets cache expiration time in minutes. |
||
199 | * |
||
200 | * @param int $minutes |
||
201 | * |
||
202 | * @return $this |
||
203 | */ |
||
204 | public function setCachingTime($minutes) |
||
209 | |||
210 | /** |
||
211 | * Adds column to grid. |
||
212 | * |
||
213 | * @param FieldConfig $column |
||
214 | * @return $this |
||
215 | */ |
||
216 | public function addColumn(FieldConfig $column) |
||
224 | |||
225 | /** |
||
226 | * Sets maximal quantity of rows per page. |
||
227 | * |
||
228 | * @param int $pageSize |
||
229 | * @return $this |
||
230 | */ |
||
231 | public function setPageSize($pageSize) |
||
236 | |||
237 | /** |
||
238 | * Returns maximal quantity of rows per page. |
||
239 | * |
||
240 | * @return int |
||
241 | */ |
||
242 | public function getPageSize() |
||
243 | { |
||
244 | return $this->page_size; |
||
245 | } |
||
246 | /** |
||
247 | * Returns maximal quantity of rows per page. |
||
248 | * |
||
249 | * @return int |
||
250 | */ |
||
251 | public function getPageSize() |
||
255 | |||
256 | public function setDefaultSort($columnName, $direction) |
||
260 | |||
261 | public function getDefaultSort() |
||
265 | } |
||
266 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: