Complex classes like PageLayoutView 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 PageLayoutView, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
24 | class PageLayoutView |
||
25 | { |
||
26 | /** |
||
27 | * Path to the locallang file |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | const LLPATH = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:'; |
||
32 | |||
33 | /** |
||
34 | * Data rendered in table of Plugin settings |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | public $data = []; |
||
39 | |||
40 | /** |
||
41 | * Flexform information |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | public $flexformData = []; |
||
46 | |||
47 | /** |
||
48 | * @var IconFactory |
||
49 | */ |
||
50 | protected $iconFactory; |
||
51 | |||
52 | /** |
||
53 | * PageLayoutView constructor |
||
54 | */ |
||
55 | public function __construct() |
||
59 | |||
60 | /** |
||
61 | * Returns information about this extension's event plugin |
||
62 | * |
||
63 | * @param array $params Parameters to the hook |
||
64 | * @return string Information about plugin |
||
65 | */ |
||
66 | public function getEventPluginSummary(array $params) |
||
92 | |||
93 | /** |
||
94 | * Returns information about this extension's user registrations plugin |
||
95 | * |
||
96 | * @param array $params Parameters to the hook |
||
97 | * @return string Information about plugin |
||
98 | */ |
||
99 | public function getUserRegPluginSummary(array $params) |
||
113 | |||
114 | /** |
||
115 | * Returns the current title of the switchableControllerAction |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | protected function getSwitchableControllerActionTitle() |
||
143 | |||
144 | /** |
||
145 | * Returns, if fields, that are only visible for list view, should be shown |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | protected function showFieldsForListViewOnly() |
||
163 | |||
164 | /** |
||
165 | * Returns the PID config for the given PID |
||
166 | * |
||
167 | * @param $pidSetting |
||
168 | * @param $sheet |
||
169 | */ |
||
170 | public function getPluginPidConfig($pidSetting, $sheet = 'sDEF') |
||
180 | |||
181 | /** |
||
182 | * |
||
183 | * |
||
184 | * @param int $id |
||
185 | * @param string $table |
||
186 | * @return string |
||
187 | */ |
||
188 | public function getRecordData($id, $table = 'pages') |
||
205 | |||
206 | /** |
||
207 | * Get the storagePage |
||
208 | * |
||
209 | * @param string $field |
||
210 | */ |
||
211 | public function getStoragePage($field) |
||
243 | |||
244 | /** |
||
245 | * Get order settings |
||
246 | * |
||
247 | * @param string $orderByField |
||
248 | * @param string $orderDirectionField |
||
249 | */ |
||
250 | public function getOrderSettings($orderByField, $orderDirectionField) |
||
268 | |||
269 | /** |
||
270 | * Get order direction |
||
271 | * @param string $orderDirectionField |
||
272 | * @return string |
||
273 | */ |
||
274 | public function getOrderDirectionSetting($orderDirectionField) |
||
285 | |||
286 | |||
287 | /** |
||
288 | * Get category conjunction if a category is selected |
||
289 | * @return void |
||
290 | */ |
||
291 | public function getCategoryConjuction() |
||
315 | |||
316 | /** |
||
317 | * Get information if override demand setting is disabled or not |
||
318 | */ |
||
319 | public function getOverrideDemandSettings() |
||
330 | |||
331 | /** |
||
332 | * Render the settings as table for Web>Page module |
||
333 | * System settings are displayed in mono font |
||
334 | * |
||
335 | * @param string $header |
||
336 | * @param string $action |
||
337 | * @param array $data |
||
338 | * @return string |
||
339 | */ |
||
340 | protected function renderSettingsAsTable($header, $action, $data) |
||
360 | |||
361 | /** |
||
362 | * Get field value from flexform configuration, |
||
363 | * including checks if flexform configuration is available |
||
364 | * |
||
365 | * @param string $key name of the key |
||
366 | * @param string $sheet name of the sheet |
||
367 | * @return string|NULL if nothing found, value if found |
||
368 | */ |
||
369 | public function getFieldFromFlexform($key, $sheet = 'sDEF') |
||
383 | |||
384 | /** |
||
385 | * Return language service instance |
||
386 | * |
||
387 | * @return \TYPO3\CMS\Lang\LanguageService |
||
388 | */ |
||
389 | public function getLanguageService() |
||
393 | |||
394 | /** |
||
395 | * Get the DocumentTemplate |
||
396 | * |
||
397 | * @return DocumentTemplate |
||
398 | */ |
||
399 | protected function getDocumentTemplate() |
||
403 | } |
||
404 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..