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) |
||
92 | |||
93 | /** |
||
94 | * Create an array of fields, titles and values that we |
||
95 | * use to setup sortable fields in the following format: |
||
96 | * |
||
97 | * - Title (the human readable name of the column) |
||
98 | * - Column (the actual field used to display data) |
||
99 | * - Sort (DB the column used to sort the data) |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function findDateFields() |
||
131 | |||
132 | /** |
||
133 | * Is the provided component a `GridField_ColumnProvider`? |
||
134 | * |
||
135 | * @param object $component The current component |
||
136 | * |
||
137 | * @return boolean |
||
138 | */ |
||
139 | protected function isColumnProvider($component) |
||
147 | |||
148 | /** |
||
149 | * Change the array keys on the provided array to the provided alternative |
||
150 | * (thanks to: https://stackoverflow.com/a/14227644/4161644) |
||
151 | * |
||
152 | * @param string $original Original key |
||
153 | * @param string $new New key |
||
154 | * @param array $array Haystack array |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | protected function changeKeys($original, $new, &$array) |
||
165 | |||
166 | /** |
||
167 | * Get `GridField` we are working with |
||
168 | * |
||
169 | * @return GridField |
||
170 | */ |
||
171 | public function getGridField() |
||
175 | |||
176 | /** |
||
177 | * Set `GridField` we are working with |
||
178 | * |
||
179 | * @param GridField $grid_field `GridField` we are working with |
||
180 | * |
||
181 | * @return self |
||
182 | */ |
||
183 | public function setGridField(GridField $grid_field) |
||
189 | |||
190 | /** |
||
191 | * Get type for this instance |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getDateType() |
||
203 | |||
204 | /** |
||
205 | * Set type for this instance |
||
206 | * |
||
207 | * @param string $date_type for this instance |
||
208 | * |
||
209 | * @return self |
||
210 | */ |
||
211 | public function setDateType(string $date_type) |
||
216 | |||
217 | /** |
||
218 | * Component doesn't provide columns |
||
219 | * |
||
220 | * @param GridField $gridField Current GridField |
||
221 | * |
||
222 | * @return array |
||
223 | */ |
||
224 | public function getColumnsHandled($gridField) |
||
228 | |||
229 | /** |
||
230 | * Component doesn't provide columns |
||
231 | * |
||
232 | * @param GridField $gridField Current GridField |
||
233 | * |
||
234 | * @return array |
||
235 | */ |
||
236 | public function getColumnMetadata($gridField, $columnName) |
||
240 | |||
241 | /** |
||
242 | * Component doesn't provide columns |
||
243 | * |
||
244 | * @param GridField $gridField Current GridField |
||
245 | * |
||
246 | * @return array |
||
247 | */ |
||
248 | public function getColumnContent($gridField, $record, $columnName) |
||
252 | |||
253 | /** |
||
254 | * Component doesn't provide columns |
||
255 | * |
||
256 | * @param GridField $gridField Current GridField |
||
257 | * |
||
258 | * @return array |
||
259 | */ |
||
260 | public function getColumnAttributes($gridField, $record, $columnName) |
||
264 | } |
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.