| Conditions | 11 |
| Paths | 67 |
| Total Lines | 75 |
| Code Lines | 51 |
| 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 |
||
| 57 | |||
| 58 | try { |
||
| 59 | if ( |
||
| 60 | StringUtility::endsWith($persistenceIdentifier, FormPersistenceManager::FORM_DEFINITION_FILE_EXTENSION) |
||
| 61 | || strpos($persistenceIdentifier, 'EXT:') === 0 |
||
| 62 | ) { |
||
| 63 | $formDefinition = $formPersistenceManager->load($persistenceIdentifier); |
||
| 64 | $formLabel = $formDefinition['label']; |
||
| 65 | } else { |
||
| 66 | $formLabel = sprintf( |
||
| 67 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.inaccessiblePersistenceIdentifier'), |
||
| 68 | $persistenceIdentifier |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | } catch (ParseErrorException $e) { |
||
| 72 | $formLabel = sprintf( |
||
| 73 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidPersistenceIdentifier'), |
||
| 74 | $persistenceIdentifier |
||
| 75 | ); |
||
| 76 | } catch (PersistenceManagerException $e) { |
||
| 77 | $formLabel = sprintf( |
||
| 78 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.inaccessiblePersistenceIdentifier'), |
||
| 79 | $persistenceIdentifier |
||
| 80 | ); |
||
| 81 | } catch (Exception $e) { |
||
| 82 | $formLabel = sprintf( |
||
| 83 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.notExistingdPersistenceIdentifier'), |
||
| 84 | $persistenceIdentifier |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | } catch (NoSuchFileException $e) { |
||
| 88 | $this->addInvalidFrameworkConfigurationFlashMessage($e); |
||
| 89 | $formLabel = sprintf( |
||
| 90 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.notExistingdPersistenceIdentifier'), |
||
| 91 | $persistenceIdentifier |
||
| 92 | ); |
||
| 93 | } catch (ParseErrorException $e) { |
||
| 94 | $this->addInvalidFrameworkConfigurationFlashMessage($e); |
||
| 95 | $formLabel = sprintf( |
||
| 96 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration'), |
||
| 97 | $persistenceIdentifier |
||
| 98 | ); |
||
| 99 | } catch (\Exception $e) { |
||
| 100 | // Top level catch - FAL throws top level exceptions on missing files, eg. in getFileInfoByIdentifier() of LocalDriver |
||
| 101 | $this->addInvalidFrameworkConfigurationFlashMessage($e); |
||
| 102 | $formLabel = $e->getMessage(); |
||
| 103 | } |
||
| 104 | } else { |
||
| 105 | $formLabel = $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.noPersistenceIdentifier'); |
||
| 106 | } |
||
| 107 | |||
| 108 | $itemContent .= $this->linkEditContent( |
||
| 109 | htmlspecialchars($formLabel), |
||
| 110 | $row |
||
| 111 | ) . '<br />'; |
||
| 112 | |||
| 113 | return $itemContent; |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @param \Exception $e |
||
| 118 | */ |
||
| 119 | protected function addInvalidFrameworkConfigurationFlashMessage(\Exception $e) |
||
| 120 | { |
||
| 121 | $messageText = sprintf( |
||
| 122 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration.text'), |
||
| 123 | $e->getMessage() |
||
| 124 | ); |
||
| 125 | |||
| 126 | GeneralUtility::makeInstance(FlashMessageService::class) |
||
| 127 | ->getMessageQueueByIdentifier('core.template.flashMessages') |
||
| 128 | ->enqueue( |
||
| 129 | GeneralUtility::makeInstance( |
||
| 130 | FlashMessage::class, |
||
| 131 | $messageText, |
||
| 132 | $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration.title'), |
||
| 147 |