Conditions | 19 |
Paths | 17 |
Total Lines | 127 |
Code Lines | 102 |
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 |
||
85 | public function main(ServerRequestInterface $request) |
||
86 | { |
||
87 | if ($this->id === 0) { |
||
88 | $this->view->assign('pageZero', true); |
||
89 | $pagesUsingTSConfig = $this->getOverviewOfPagesUsingTSConfig(); |
||
90 | if (count($pagesUsingTSConfig) > 0) { |
||
91 | $this->view->assign('overviewOfPagesUsingTSConfig', $pagesUsingTSConfig); |
||
92 | } |
||
93 | } else { |
||
94 | if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) { |
||
95 | $rootLine = BackendUtility::BEgetRootLine($this->id, '', true); |
||
96 | /** @var array<string, string> $TSparts */ |
||
97 | $TSparts = GeneralUtility::makeInstance(PageTsConfigLoader::class)->collect($rootLine); |
||
98 | $lines = []; |
||
99 | $pUids = []; |
||
100 | |||
101 | foreach ($TSparts as $k => $v) { |
||
102 | $line = []; |
||
103 | if ($k === 'default') { |
||
104 | $line['defaultPageTSconfig'] = 1; |
||
105 | } else { |
||
106 | // Remove the "page_" prefix |
||
107 | [, $pageId] = explode('_', $k, 3); |
||
108 | $pageId = (int)$pageId; |
||
109 | $pUids[] = $pageId; |
||
110 | $row = BackendUtility::getRecordWSOL('pages', $pageId); |
||
111 | |||
112 | $icon = $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL); |
||
113 | $urlParameters = [ |
||
114 | 'edit' => [ |
||
115 | 'pages' => [ |
||
116 | $pageId => 'edit', |
||
117 | ] |
||
118 | ], |
||
119 | 'columnsOnly' => 'TSconfig,tsconfig_includes', |
||
120 | 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
121 | ]; |
||
122 | $line['editIcon'] = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters); |
||
123 | $line['editTitle'] = 'editTSconfig'; |
||
124 | $line['title'] = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']) |
||
125 | . ' ' . htmlspecialchars(BackendUtility::getRecordTitle('pages', $row)); |
||
126 | } |
||
127 | $tsparser = GeneralUtility::makeInstance(TypoScriptParser::class); |
||
128 | $tsparser->lineNumberOffset = 0; |
||
129 | $line['content'] = $tsparser->doSyntaxHighlight(trim($v) . LF); |
||
130 | $lines[] = $line; |
||
131 | } |
||
132 | |||
133 | if (!empty($pUids)) { |
||
134 | $urlParameters = [ |
||
135 | 'edit' => [ |
||
136 | 'pages' => [ |
||
137 | implode(',', $pUids) => 'edit', |
||
138 | ] |
||
139 | ], |
||
140 | 'columnsOnly' => 'TSconfig,tsconfig_includes', |
||
141 | 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri() |
||
142 | ]; |
||
143 | $url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters); |
||
144 | $editIcon = htmlspecialchars($url); |
||
145 | $editTitle = 'editTSconfig_all'; |
||
146 | } else { |
||
147 | $editIcon = ''; |
||
148 | $editTitle = ''; |
||
149 | } |
||
150 | |||
151 | $this->view->assign('tsconfParts99', true); |
||
152 | $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', '', '|')); |
||
153 | $this->view->assign('lines', $lines); |
||
154 | $this->view->assign('editIcon', $editIcon); |
||
155 | $this->view->assign('editTitle', $editTitle); |
||
156 | } else { |
||
157 | $this->view->assign('tsconfParts99', false); |
||
158 | // Defined global here! |
||
159 | $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class); |
||
160 | $tmpl->ext_expandAllNotes = 1; |
||
161 | $tmpl->ext_noPMicons = 1; |
||
162 | |||
163 | $pageTsConfig = BackendUtility::getPagesTSconfig($this->id); |
||
164 | switch ($this->pObj->MOD_SETTINGS['tsconf_parts']) { |
||
165 | case '1': |
||
166 | $pageTsConfig = $pageTsConfig['mod.'] ?? []; |
||
167 | break; |
||
168 | case '1a': |
||
169 | $pageTsConfig = $pageTsConfig['mod.']['web_layout.'] ?? []; |
||
170 | break; |
||
171 | case '1b': |
||
172 | $pageTsConfig = $pageTsConfig['mod.']['web_view.'] ?? []; |
||
173 | break; |
||
174 | case '1c': |
||
175 | $pageTsConfig = $pageTsConfig['mod.']['web_modules.'] ?? []; |
||
176 | break; |
||
177 | case '1d': |
||
178 | $pageTsConfig = $pageTsConfig['mod.']['web_list.'] ?? []; |
||
179 | break; |
||
180 | case '1e': |
||
181 | $pageTsConfig = $pageTsConfig['mod.']['web_info.'] ?? []; |
||
182 | break; |
||
183 | case '1g': |
||
184 | $pageTsConfig = $pageTsConfig['mod.']['web_ts.'] ?? []; |
||
185 | break; |
||
186 | case '2': |
||
187 | $pageTsConfig = $pageTsConfig['RTE.'] ?? []; |
||
188 | break; |
||
189 | case '5': |
||
190 | $pageTsConfig = $pageTsConfig['TCEFORM.'] ?? []; |
||
191 | break; |
||
192 | case '6': |
||
193 | $pageTsConfig = $pageTsConfig['TCEMAIN.'] ?? []; |
||
194 | break; |
||
195 | case '7': |
||
196 | $pageTsConfig = $pageTsConfig['TCAdefaults.'] ?? []; |
||
197 | break; |
||
198 | case '4': |
||
199 | $pageTsConfig = $pageTsConfig['user.'] ?? []; |
||
200 | break; |
||
201 | default: |
||
202 | // Entire array |
||
203 | } |
||
204 | |||
205 | $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', '', '|')); |
||
206 | $this->view->assign('tree', $tmpl->ext_getObjTree($pageTsConfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'])); |
||
207 | } |
||
208 | $this->view->assign('alphaSort', BackendUtility::getFuncCheck($this->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"')); |
||
209 | $this->view->assign('dropdownMenu', BackendUtility::getDropdownMenu($this->id, 'SET[tsconf_parts]', $this->pObj->MOD_SETTINGS['tsconf_parts'], $this->pObj->MOD_MENU['tsconf_parts'])); |
||
210 | } |
||
211 | return $this->view->render(); |
||
212 | } |
||
406 |