| Conditions | 3 |
| Paths | 4 |
| Total Lines | 67 |
| Code Lines | 47 |
| 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 |
||
| 165 | protected function renderContent(): void |
||
| 166 | { |
||
| 167 | $assigns = []; |
||
| 168 | $assigns['moduleUrlTceFile'] = (string)$this->uriBuilder->buildUriFromRoute('tce_file'); |
||
| 169 | $assigns['returnUrl'] = $this->returnUrl; |
||
| 170 | |||
| 171 | if ($this->fileOrFolderObject instanceof Folder) { |
||
| 172 | $fileIdentifier = $this->fileOrFolderObject->getCombinedIdentifier(); |
||
| 173 | $targetLabel = 'file_rename.php.label.target.folder'; |
||
| 174 | } else { |
||
| 175 | $fileIdentifier = $this->fileOrFolderObject->getUid(); |
||
| 176 | $targetLabel = 'file_rename.php.label.target.file'; |
||
| 177 | $assigns['conflictMode'] = DuplicationBehavior::cast(DuplicationBehavior::RENAME); |
||
| 178 | $assigns['destination'] = $this->fileOrFolderObject->getParentFolder()->getCombinedIdentifier(); |
||
| 179 | } |
||
| 180 | |||
| 181 | $assigns['fileName'] = $this->fileOrFolderObject->getName(); |
||
| 182 | $assigns['fileIdentifier'] = $fileIdentifier; |
||
| 183 | $assigns['fieldLabel'] = $targetLabel; |
||
| 184 | |||
| 185 | // Create buttons |
||
| 186 | $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); |
||
| 187 | |||
| 188 | // csh button |
||
| 189 | $cshButton = $buttonBar->makeHelpButton() |
||
| 190 | ->setModuleName('xMOD_csh_corebe') |
||
| 191 | ->setFieldName('file_rename'); |
||
| 192 | $buttonBar->addButton($cshButton); |
||
| 193 | |||
| 194 | // back button |
||
| 195 | if ($this->returnUrl) { |
||
| 196 | $backButton = $buttonBar->makeLinkButton() |
||
| 197 | ->setHref($this->returnUrl) |
||
| 198 | ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack')) |
||
| 199 | ->setIcon($this->iconFactory->getIcon('actions-close', Icon::SIZE_SMALL)); |
||
| 200 | $buttonBar->addButton($backButton); |
||
| 201 | } |
||
| 202 | |||
| 203 | // Save and Close button |
||
| 204 | $saveAndCloseButton = $buttonBar->makeInputButton() |
||
| 205 | ->setName('_saveandclose') |
||
| 206 | ->setValue('1') |
||
| 207 | ->setShowLabelText(true) |
||
| 208 | ->setClasses('t3js-submit-file-rename') |
||
| 209 | ->setForm('RenameFileController') |
||
| 210 | ->setTitle($this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_edit.php.saveAndClose')) |
||
| 211 | ->setIcon($this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL)); |
||
| 212 | |||
| 213 | $buttonBar->addButton($saveAndCloseButton, ButtonBar::BUTTON_POSITION_LEFT, 20); |
||
| 214 | |||
| 215 | $this->pageRenderer->addInlineLanguageLabelArray([ |
||
| 216 | 'file_rename.actions.cancel' => $this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_rename.actions.cancel'), |
||
| 217 | 'file_rename.actions.rename' => $this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_rename.actions.rename'), |
||
| 218 | 'file_rename.actions.override' => $this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_rename.actions.override'), |
||
| 219 | 'file_rename.exists.title' => $this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_rename.exists.title'), |
||
| 220 | 'file_rename.exists.description' => $this->getLanguageService()->sL('LLL:EXT:filelist/Resources/Private/Language/locallang.xlf:file_rename.exists.description'), |
||
| 221 | ]); |
||
| 222 | |||
| 223 | // Rendering of the output via fluid |
||
| 224 | $view = GeneralUtility::makeInstance(StandaloneView::class); |
||
| 225 | $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]); |
||
| 226 | $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]); |
||
| 227 | $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName( |
||
| 228 | 'EXT:filelist/Resources/Private/Templates/File/RenameFile.html' |
||
| 229 | )); |
||
| 230 | $view->assignMultiple($assigns); |
||
| 231 | $this->moduleTemplate->setContent($view->render()); |
||
| 232 | } |
||
| 242 |