Conditions | 8 |
Paths | 12 |
Total Lines | 61 |
Code Lines | 41 |
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 |
||
138 | public function main() |
||
139 | { |
||
140 | // Checking for more than one template an if, set a menu... |
||
141 | $manyTemplatesMenu = $this->pObj->templateMenu($this->request); |
||
142 | $template_uid = 0; |
||
143 | if ($manyTemplatesMenu) { |
||
144 | $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; |
||
145 | } |
||
146 | // Initialize |
||
147 | $existTemplate = $this->initialize_editor($this->id, $template_uid); |
||
148 | $saveId = 0; |
||
149 | if ($existTemplate) { |
||
150 | $saveId = $this->templateRow['_ORIG_uid'] ?: $this->templateRow['uid']; |
||
151 | } |
||
152 | // Create extension template |
||
153 | $newId = $this->pObj->createTemplate($this->id, (int)$saveId); |
||
154 | if ($newId) { |
||
155 | // Switch to new template |
||
156 | $urlParameters = [ |
||
157 | 'id' => $this->id, |
||
158 | 'SET[templatesOnPage]' => $newId |
||
159 | ]; |
||
160 | $url = $this->uriBuilder->buildUriFromRoute('web_ts', $urlParameters); |
||
161 | throw new PropagateResponseException(new RedirectResponse($url, 303), 1607271781); |
||
162 | } |
||
163 | if ($existTemplate) { |
||
164 | $lang = $this->getLanguageService(); |
||
165 | $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_info.xlf'); |
||
166 | $assigns = []; |
||
167 | $assigns['templateRecord'] = $this->templateRow; |
||
168 | $assigns['manyTemplatesMenu'] = $manyTemplatesMenu; |
||
169 | |||
170 | // Processing: |
||
171 | $tableRows = []; |
||
172 | $tableRows[] = $this->tableRowData($lang->getLL('title'), $this->templateRow['title'], 'title', $this->templateRow['uid']); |
||
173 | $tableRows[] = $this->tableRowData($lang->getLL('description'), $this->templateRow['description'], 'description', $this->templateRow['uid']); |
||
174 | $tableRows[] = $this->tableRowData($lang->getLL('constants'), sprintf($lang->getLL('editToView'), trim($this->templateRow['constants']) ? count(explode(LF, $this->templateRow['constants'])) : 0), 'constants', $this->templateRow['uid']); |
||
175 | $tableRows[] = $this->tableRowData($lang->getLL('setup'), sprintf($lang->getLL('editToView'), trim($this->templateRow['config']) ? count(explode(LF, $this->templateRow['config'])) : 0), 'config', $this->templateRow['uid']); |
||
176 | $assigns['tableRows'] = $tableRows; |
||
177 | |||
178 | // Edit all icon: |
||
179 | $urlParameters = [ |
||
180 | 'edit' => [ |
||
181 | 'sys_template' => [ |
||
182 | $this->templateRow['uid'] => 'edit' |
||
183 | ] |
||
184 | ], |
||
185 | 'createExtension' => 0, |
||
186 | 'returnUrl' => $this->request->getAttribute('normalizedParams')->getRequestUri() |
||
187 | ]; |
||
188 | $assigns['editAllUrl'] = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters); |
||
189 | |||
190 | // Rendering of the output via fluid |
||
191 | $view = GeneralUtility::makeInstance(StandaloneView::class); |
||
192 | $view->setTemplatePathAndFilename('EXT:tstemplate/Resources/Private/Templates/InformationModule.html'); |
||
193 | $view->assignMultiple($assigns); |
||
194 | $theOutput = $view->render(); |
||
195 | } else { |
||
196 | $theOutput = $this->pObj->noTemplate(1); |
||
197 | } |
||
198 | return $theOutput; |
||
199 | } |
||
209 |