Complex classes like AdministrationController 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 AdministrationController, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
36 | class AdministrationController extends AbstractController |
||
37 | { |
||
38 | const LANG_FILE = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:'; |
||
39 | |||
40 | /** |
||
41 | * Backend Template Container |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; |
||
46 | |||
47 | /** |
||
48 | * CustomNotificationLogRepository |
||
49 | * |
||
50 | * @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
||
51 | */ |
||
52 | protected $customNotificationLogRepository = null; |
||
53 | |||
54 | /** |
||
55 | * ExportService |
||
56 | * |
||
57 | * @var \DERHANSEN\SfEventMgt\Service\ExportService |
||
58 | */ |
||
59 | protected $exportService = null; |
||
60 | |||
61 | /** |
||
62 | * SettingsService |
||
63 | * |
||
64 | * @var \DERHANSEN\SfEventMgt\Service\SettingsService |
||
65 | */ |
||
66 | protected $settingsService = null; |
||
67 | |||
68 | /** |
||
69 | * Backend User Session Service |
||
70 | * |
||
71 | * @var \DERHANSEN\SfEventMgt\Service\BeUserSessionService |
||
72 | */ |
||
73 | protected $beUserSessionService = null; |
||
74 | |||
75 | /** |
||
76 | * @var \DERHANSEN\SfEventMgt\Service\MaintenanceService |
||
77 | */ |
||
78 | protected $maintenanceService = null; |
||
79 | |||
80 | /** |
||
81 | * The current page uid |
||
82 | * |
||
83 | * @var int |
||
84 | */ |
||
85 | protected $pid = 0; |
||
86 | |||
87 | /** |
||
88 | * BackendTemplateContainer |
||
89 | * |
||
90 | * @var BackendTemplateView |
||
91 | 2 | */ |
|
92 | protected $view; |
||
93 | 2 | ||
94 | 2 | /** |
|
95 | * @var IconFactory |
||
96 | */ |
||
97 | protected $iconFactory = null; |
||
98 | |||
99 | /** |
||
100 | * DI for $customNotificationLogRepository |
||
101 | 4 | * |
|
102 | * @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
||
103 | 4 | */ |
|
104 | 2 | public function injectCustomNotificationLogRepository( |
|
109 | 4 | ||
110 | 4 | /** |
|
111 | 4 | * DI for $exportService |
|
112 | 4 | * |
|
113 | 4 | * @param Service\ExportService $exportService |
|
114 | 4 | */ |
|
115 | 4 | public function injectExportService(\DERHANSEN\SfEventMgt\Service\ExportService $exportService) |
|
119 | 4 | ||
120 | 4 | /** |
|
121 | * DI for $settingsService |
||
122 | * |
||
123 | * @param Service\SettingsService $settingsService |
||
124 | */ |
||
125 | public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService) |
||
129 | |||
130 | 8 | /** |
|
131 | * DI for $beUserSessionService |
||
132 | * |
||
133 | 8 | * @param Service\BeUserSessionService $beUserSessionService |
|
134 | */ |
||
135 | 8 | public function injectBeUserSessionService(\DERHANSEN\SfEventMgt\Service\BeUserSessionService $beUserSessionService) |
|
139 | |||
140 | 8 | /** |
|
141 | 4 | * DI for $iconFactory |
|
142 | 4 | * |
|
143 | * @param IconFactory $iconFactory |
||
144 | 8 | */ |
|
145 | 2 | public function injectIconFactory(IconFactory $iconFactory) |
|
149 | |||
150 | 8 | /** |
|
151 | 8 | * @param Service\MaintenanceService $maintenanceService |
|
152 | 8 | */ |
|
153 | 8 | public function injectMaintenanceService(\DERHANSEN\SfEventMgt\Service\MaintenanceService $maintenanceService) |
|
157 | |||
158 | /** |
||
159 | * Set up the doc header properly here |
||
160 | * |
||
161 | * @param ViewInterface $view |
||
162 | 2 | * |
|
163 | * @return void |
||
164 | 2 | */ |
|
165 | 2 | protected function initializeView(ViewInterface $view) |
|
191 | 2 | ||
192 | 2 | /** |
|
193 | 2 | * Register docHeaderButtons |
|
194 | 2 | * |
|
195 | 2 | * @return void |
|
196 | */ |
||
197 | protected function registerDocHeaderButtons() |
||
255 | |||
256 | /** |
||
257 | * Redirect to tceform creating a new record |
||
258 | * |
||
259 | * @param string $table table name |
||
260 | * @return void |
||
261 | */ |
||
262 | private function redirectToCreateNewRecord($table) |
||
287 | |||
288 | /** |
||
289 | * Initialize action |
||
290 | * |
||
291 | * @return void |
||
292 | */ |
||
293 | public function initializeAction() |
||
297 | |||
298 | /** |
||
299 | * Set date format for fields startDate and endDate |
||
300 | * |
||
301 | * @return void |
||
302 | */ |
||
303 | public function initializeListAction() |
||
323 | |||
324 | /** |
||
325 | * List action for backend module |
||
326 | * |
||
327 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand |
||
328 | * @param array $overwriteDemand OverwriteDemand |
||
329 | * |
||
330 | * @return void |
||
331 | */ |
||
332 | public function listAction(SearchDemand $searchDemand = null, array $overwriteDemand = []) |
||
364 | |||
365 | /** |
||
366 | * Export registrations for a given event |
||
367 | * |
||
368 | * @param int $eventUid Event UID |
||
369 | * |
||
370 | * @return void |
||
371 | */ |
||
372 | public function exportAction($eventUid) |
||
377 | |||
378 | /** |
||
379 | * Handles expired registrations |
||
380 | * |
||
381 | * @return void |
||
382 | */ |
||
383 | public function handleExpiredRegistrationsAction() |
||
396 | |||
397 | /** |
||
398 | * The index notify action |
||
399 | * |
||
400 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
||
401 | * |
||
402 | * @return void |
||
403 | */ |
||
404 | public function indexNotifyAction(Event $event) |
||
414 | |||
415 | /** |
||
416 | * Create new event action |
||
417 | */ |
||
418 | public function newEventAction() |
||
422 | |||
423 | /** |
||
424 | * Create new location action |
||
425 | */ |
||
426 | public function newLocationAction() |
||
430 | |||
431 | /** |
||
432 | * Create new organisator action |
||
433 | */ |
||
434 | public function newOrganisatorAction() |
||
438 | |||
439 | /** |
||
440 | * Create new speaker action |
||
441 | */ |
||
442 | public function newSpeakerAction() |
||
446 | |||
447 | /** |
||
448 | * Notify action |
||
449 | * |
||
450 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
||
451 | * @param string $customNotification CustomNotification |
||
452 | * |
||
453 | * @return void |
||
454 | */ |
||
455 | public function notifyAction(Event $event, $customNotification) |
||
471 | |||
472 | /** |
||
473 | * Shows the settings error view |
||
474 | * |
||
475 | * @return void |
||
476 | */ |
||
477 | public function settingsErrorAction() |
||
480 | |||
481 | /** |
||
482 | * Suppress default validation messages |
||
483 | * |
||
484 | * @return bool |
||
485 | */ |
||
486 | protected function getErrorFlashMessage() |
||
490 | |||
491 | /** |
||
492 | * Get a CSRF token |
||
493 | * |
||
494 | * @param bool $tokenOnly Set it to TRUE to get only the token, otherwise including the &moduleToken= as prefix |
||
495 | * @return string |
||
496 | */ |
||
497 | protected function getToken(bool $tokenOnly = false): string |
||
513 | |||
514 | /** |
||
515 | * Returns the LanguageService |
||
516 | * |
||
517 | * @return LanguageService |
||
518 | */ |
||
519 | protected function getLanguageService(): LanguageService |
||
523 | |||
524 | /** |
||
525 | * Returns an array with possible order directions |
||
526 | * |
||
527 | * @return array |
||
528 | */ |
||
529 | public function getOrderDirections() |
||
536 | |||
537 | /** |
||
538 | * Returns an array with possible orderBy fields |
||
539 | * |
||
540 | * @return array |
||
541 | */ |
||
542 | public function getOrderByFields() |
||
550 | } |
||
551 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.