Conditions | 11 |
Paths | 66 |
Total Lines | 79 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
48 | public function getExtensionSummary(array $params) |
||
49 | { |
||
50 | if ('calendarize_calendar' !== $params['row']['list_type']) { |
||
51 | return ''; |
||
52 | } |
||
53 | |||
54 | $this->flexFormService = GeneralUtility::makeInstance(FlexFormService::class); |
||
55 | $this->flexFormService->load($params['row']['pi_flexform']); |
||
56 | if (!$this->flexFormService->isValid()) { |
||
57 | return ''; |
||
58 | } |
||
59 | |||
60 | $extensionIcon = IconUtility::getByExtensionKey('calendarize', true); |
||
61 | $extensionIconUsage = PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName($extensionIcon)); |
||
62 | $this->layoutService = GeneralUtility::makeInstance(ContentElementLayoutService::class); |
||
63 | $this->layoutService->setTitle('<img src="' . $extensionIconUsage . '" width="32" height="32" /> Calendarize'); |
||
64 | |||
65 | $actions = $this->flexFormService->get('switchableControllerActions', 'main'); |
||
66 | $parts = GeneralUtility::trimExplode(';', $actions, true); |
||
67 | $parts = \array_map(function ($element) { |
||
68 | $split = \explode('->', $element); |
||
69 | |||
70 | return \ucfirst($split[1]); |
||
71 | }, $parts); |
||
72 | $actionKey = \lcfirst(\implode('', $parts)); |
||
73 | |||
74 | $this->layoutService->addRow(TranslateUtility::get('mode'), TranslateUtility::get('mode.' . $actionKey)); |
||
75 | |||
76 | $pluginConfiguration = (int) $this->flexFormService->get('settings.pluginConfiguration', 'main'); |
||
77 | if ($pluginConfiguration) { |
||
78 | $table = 'tx_calendarize_domain_model_pluginconfiguration'; |
||
79 | |||
80 | $row = HelperUtility::getDatabaseConnection($table)->select( |
||
81 | ['*'], |
||
82 | $table, |
||
83 | ['uid' => $pluginConfiguration] |
||
84 | )->fetch(); |
||
85 | $this->layoutService->addRow( |
||
86 | TranslateUtility::get('tx_calendarize_domain_model_pluginconfiguration'), |
||
87 | BackendUtility::getRecordTitle($table, $row) |
||
88 | ); |
||
89 | } |
||
90 | |||
91 | if ('' !== \trim((string) $this->flexFormService->get('settings.configuration', 'general'))) { |
||
92 | $this->layoutService->addRow( |
||
93 | TranslateUtility::get('configuration'), |
||
94 | $this->flexFormService->get('settings.configuration', 'general') |
||
95 | ); |
||
96 | } |
||
97 | |||
98 | if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) { |
||
99 | $this->layoutService->addRow(TranslateUtility::get('hide.pagination.teaser'), '!!!'); |
||
100 | } |
||
101 | $useRelativeDate = (bool) $this->flexFormService->get('settings.useRelativeDate', 'main'); |
||
102 | if ($useRelativeDate) { |
||
103 | $overrideStartRelative = $this->flexFormService->get('settings.overrideStartRelative', 'main'); |
||
104 | if ($overrideStartRelative) { |
||
105 | $this->layoutService->addRow(TranslateUtility::get('override.startrelative'), $overrideStartRelative); |
||
106 | } |
||
107 | $overrideEndRelative = $this->flexFormService->get('settings.overrideEndRelative', 'main'); |
||
108 | if ($overrideEndRelative) { |
||
109 | $this->layoutService->addRow(TranslateUtility::get('override.endrelative'), $overrideEndRelative); |
||
110 | } |
||
111 | |||
112 | } else { |
||
113 | $overrideStartDate = (int) $this->flexFormService->get('settings.overrideStartdate', 'main'); |
||
114 | if ($overrideStartDate) { |
||
115 | $this->layoutService->addRow(TranslateUtility::get('override.startdate'), \date('d.m.y H:i', $overrideStartDate)); |
||
116 | } |
||
117 | $overrideEndDate = (int) $this->flexFormService->get('settings.overrideEnddate', 'main'); |
||
118 | if ($overrideEndDate) { |
||
119 | $this->layoutService->addRow(TranslateUtility::get('override.enddate'), \date('d.m.y H:i', $overrideEndDate)); |
||
120 | } |
||
121 | } |
||
122 | |||
123 | $this->addPageIdsToTable(); |
||
124 | |||
125 | return $this->layoutService->render(); |
||
126 | } |
||
127 | |||
154 |