1 | <?php |
||
18 | class GridFieldColumnDateFormatter implements GridField_ColumnProvider |
||
19 | { |
||
20 | use Configurable; |
||
21 | |||
22 | /** |
||
23 | * `GridField` we are working with |
||
24 | * |
||
25 | * @var GridField |
||
26 | */ |
||
27 | protected $grid_field; |
||
28 | |||
29 | /** |
||
30 | * Overwrite the date format (provided by config) |
||
31 | * for this instance |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $date_type; |
||
36 | |||
37 | /** |
||
38 | * The date formatting method to use (this corresponds |
||
39 | * to a Date method on the Date/DateTime data type). |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private static $default_date_type = ".Nice"; |
||
44 | |||
45 | /** |
||
46 | * Find the column/header provider for this gridfield and then augment the |
||
47 | * columns so that any dates are re-formatted. |
||
48 | * |
||
49 | * @param GridField $gridField Current gridfield |
||
|
|||
50 | * @param array $columns List reference of all column names. |
||
51 | * |
||
52 | * @return null |
||
53 | */ |
||
54 | public function augmentColumns($grid_field, &$columns) |
||
107 | |||
108 | /** |
||
109 | * Create an array of fields, titles and values that we |
||
110 | * use to setup sortable fields in the following format: |
||
111 | * |
||
112 | * - Title (the human readable name of the column) |
||
113 | * - Column (the actual field used to display data) |
||
114 | * - Sort (DB the column used to sort the data) |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | protected function findDateFields() |
||
146 | |||
147 | /** |
||
148 | * Is the provided component a `GridField_ColumnProvider`? |
||
149 | * |
||
150 | * @param object $component The current component |
||
151 | * |
||
152 | * @return boolean |
||
153 | */ |
||
154 | protected function isColumnProvider($component) |
||
162 | |||
163 | /** |
||
164 | * Change the array keys on the provided array to the provided alternative |
||
165 | * (thanks to: https://stackoverflow.com/a/14227644/4161644) |
||
166 | * |
||
167 | * @param string $original Original key |
||
168 | * @param string $new New key |
||
169 | * @param array $array Haystack array |
||
170 | * |
||
171 | * @return array |
||
172 | */ |
||
173 | protected function changeKeys($original, $new, &$array) |
||
180 | |||
181 | /** |
||
182 | * Get `GridField` we are working with |
||
183 | * |
||
184 | * @return GridField |
||
185 | */ |
||
186 | public function getGridField() |
||
190 | |||
191 | /** |
||
192 | * Set `GridField` we are working with |
||
193 | * |
||
194 | * @param GridField $grid_field `GridField` we are working with |
||
195 | * |
||
196 | * @return self |
||
197 | */ |
||
198 | public function setGridField(GridField $grid_field) |
||
204 | |||
205 | /** |
||
206 | * Get type for this instance |
||
207 | * |
||
208 | * @return string |
||
209 | */ |
||
210 | public function getDateType() |
||
218 | |||
219 | /** |
||
220 | * Set type for this instance |
||
221 | * |
||
222 | * @param string $date_type for this instance |
||
223 | * |
||
224 | * @return self |
||
225 | */ |
||
226 | public function setDateType(string $date_type) |
||
231 | |||
232 | /** |
||
233 | * Component doesn't provide columns |
||
234 | * |
||
235 | * @param GridField $gridField Current GridField |
||
236 | * |
||
237 | * @return array |
||
238 | */ |
||
239 | public function getColumnsHandled($gridField) |
||
243 | |||
244 | /** |
||
245 | * Component doesn't provide columns |
||
246 | * |
||
247 | * @param GridField $gridField Current GridField |
||
248 | * |
||
249 | * @return array |
||
250 | */ |
||
251 | public function getColumnMetadata($gridField, $columnName) |
||
255 | |||
256 | /** |
||
257 | * Component doesn't provide columns |
||
258 | * |
||
259 | * @param GridField $gridField Current GridField |
||
260 | * |
||
261 | * @return array |
||
262 | */ |
||
263 | public function getColumnContent($gridField, $record, $columnName) |
||
267 | |||
268 | /** |
||
269 | * Component doesn't provide columns |
||
270 | * |
||
271 | * @param GridField $gridField Current GridField |
||
272 | * |
||
273 | * @return array |
||
274 | */ |
||
275 | public function getColumnAttributes($gridField, $record, $columnName) |
||
279 | } |
||
280 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.