| Conditions | 6 |
| Paths | 6 |
| Total Lines | 183 |
| Code Lines | 114 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 42 | protected function getDefaultStructureDefinition(): array |
||
| 43 | { |
||
| 44 | $filePermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask']; |
||
| 45 | $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']; |
||
| 46 | if (Environment::getPublicPath() === Environment::getProjectPath()) { |
||
| 47 | $structure = [ |
||
| 48 | // Note that root node has no trailing slash like all others |
||
| 49 | 'name' => Environment::getPublicPath(), |
||
| 50 | 'targetPermission' => $directoryPermission, |
||
| 51 | 'children' => [ |
||
| 52 | [ |
||
| 53 | 'name' => 'typo3temp', |
||
| 54 | 'type' => DirectoryNode::class, |
||
| 55 | 'targetPermission' => $directoryPermission, |
||
| 56 | 'children' => [ |
||
| 57 | [ |
||
| 58 | 'name' => 'index.html', |
||
| 59 | 'type' => FileNode::class, |
||
| 60 | 'targetPermission' => $filePermission, |
||
| 61 | 'targetContent' => '', |
||
| 62 | ], |
||
| 63 | $this->getTemporaryAssetsFolderStructure(), |
||
| 64 | [ |
||
| 65 | 'name' => 'var', |
||
| 66 | 'type' => DirectoryNode::class, |
||
| 67 | 'targetPermission' => $directoryPermission, |
||
| 68 | 'children' => [ |
||
| 69 | [ |
||
| 70 | 'name' => '.htaccess', |
||
| 71 | 'type' => FileNode::class, |
||
| 72 | 'targetPermission' => $filePermission, |
||
| 73 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess', |
||
| 74 | ], |
||
| 75 | [ |
||
| 76 | 'name' => 'charset', |
||
| 77 | 'type' => DirectoryNode::class, |
||
| 78 | 'targetPermission' => $directoryPermission, |
||
| 79 | ], |
||
| 80 | [ |
||
| 81 | 'name' => 'cache', |
||
| 82 | 'type' => DirectoryNode::class, |
||
| 83 | 'targetPermission' => $directoryPermission, |
||
| 84 | ], |
||
| 85 | [ |
||
| 86 | 'name' => 'lock', |
||
| 87 | 'type' => DirectoryNode::class, |
||
| 88 | 'targetPermission' => $directoryPermission, |
||
| 89 | ] |
||
| 90 | ] |
||
| 91 | ], |
||
| 92 | ], |
||
| 93 | ], |
||
| 94 | [ |
||
| 95 | 'name' => 'typo3conf', |
||
| 96 | 'type' => DirectoryNode::class, |
||
| 97 | 'targetPermission' => $directoryPermission, |
||
| 98 | 'children' => [ |
||
| 99 | [ |
||
| 100 | 'name' => 'ext', |
||
| 101 | 'type' => DirectoryNode::class, |
||
| 102 | 'targetPermission' => $directoryPermission, |
||
| 103 | ], |
||
| 104 | [ |
||
| 105 | 'name' => 'l10n', |
||
| 106 | 'type' => DirectoryNode::class, |
||
| 107 | 'targetPermission' => $directoryPermission, |
||
| 108 | ], |
||
| 109 | ], |
||
| 110 | ], |
||
| 111 | $this->getFileadminStructure(), |
||
| 112 | ], |
||
| 113 | ]; |
||
| 114 | |||
| 115 | // Have a default .htaccess if running apache web server or a default web.config if running IIS |
||
| 116 | if ($this->isApacheServer()) { |
||
| 117 | $structure['children'][] = [ |
||
| 118 | 'name' => '.htaccess', |
||
| 119 | 'type' => FileNode::class, |
||
| 120 | 'targetPermission' => $filePermission, |
||
| 121 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess', |
||
| 122 | ]; |
||
| 123 | } elseif ($this->isMicrosoftIisServer()) { |
||
| 124 | $structure['children'][] = [ |
||
| 125 | 'name' => 'web.config', |
||
| 126 | 'type' => FileNode::class, |
||
| 127 | 'targetPermission' => $filePermission, |
||
| 128 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/root-web-config', |
||
| 129 | ]; |
||
| 130 | } |
||
| 131 | } else { |
||
| 132 | // This is when the public path is a subfolder (e.g. public/ or web/) |
||
| 133 | $publicPath = substr(Environment::getPublicPath(), strlen(Environment::getProjectPath())+1); |
||
| 134 | |||
| 135 | $publicPathSubStructure = [ |
||
| 136 | [ |
||
| 137 | 'name' => 'typo3temp', |
||
| 138 | 'type' => DirectoryNode::class, |
||
| 139 | 'targetPermission' => $directoryPermission, |
||
| 140 | 'children' => [ |
||
| 141 | [ |
||
| 142 | 'name' => 'index.html', |
||
| 143 | 'type' => FileNode::class, |
||
| 144 | 'targetPermission' => $filePermission, |
||
| 145 | 'targetContent' => '', |
||
| 146 | ], |
||
| 147 | $this->getTemporaryAssetsFolderStructure(), |
||
| 148 | ], |
||
| 149 | ], |
||
| 150 | [ |
||
| 151 | 'name' => 'typo3conf', |
||
| 152 | 'type' => DirectoryNode::class, |
||
| 153 | 'targetPermission' => $directoryPermission, |
||
| 154 | 'children' => [ |
||
| 155 | [ |
||
| 156 | 'name' => 'ext', |
||
| 157 | 'type' => DirectoryNode::class, |
||
| 158 | 'targetPermission' => $directoryPermission, |
||
| 159 | ], |
||
| 160 | ], |
||
| 161 | ], |
||
| 162 | $this->getFileadminStructure(), |
||
| 163 | ]; |
||
| 164 | |||
| 165 | // Have a default .htaccess if running apache web server or a default web.config if running IIS |
||
| 166 | if ($this->isApacheServer()) { |
||
| 167 | $publicPathSubStructure[] = [ |
||
| 168 | 'name' => '.htaccess', |
||
| 169 | 'type' => FileNode::class, |
||
| 170 | 'targetPermission' => $filePermission, |
||
| 171 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess', |
||
| 172 | ]; |
||
| 173 | } elseif ($this->isMicrosoftIisServer()) { |
||
| 174 | $publicPathSubStructure[] = [ |
||
| 175 | 'name' => 'web.config', |
||
| 176 | 'type' => FileNode::class, |
||
| 177 | 'targetPermission' => $filePermission, |
||
| 178 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/root-web-config', |
||
| 179 | ]; |
||
| 180 | } |
||
| 181 | |||
| 182 | $structure = [ |
||
| 183 | // Note that root node has no trailing slash like all others |
||
| 184 | 'name' => Environment::getProjectPath(), |
||
| 185 | 'targetPermission' => $directoryPermission, |
||
| 186 | 'children' => [ |
||
| 187 | $this->getPublicStructure($publicPath, $publicPathSubStructure), |
||
| 188 | [ |
||
| 189 | 'name' => 'var', |
||
| 190 | 'type' => DirectoryNode::class, |
||
| 191 | 'targetPermission' => $directoryPermission, |
||
| 192 | 'children' => [ |
||
| 193 | [ |
||
| 194 | 'name' => '.htaccess', |
||
| 195 | 'type' => FileNode::class, |
||
| 196 | 'targetPermission' => $filePermission, |
||
| 197 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess', |
||
| 198 | ], |
||
| 199 | [ |
||
| 200 | 'name' => 'charset', |
||
| 201 | 'type' => DirectoryNode::class, |
||
| 202 | 'targetPermission' => $directoryPermission, |
||
| 203 | ], |
||
| 204 | [ |
||
| 205 | 'name' => 'cache', |
||
| 206 | 'type' => DirectoryNode::class, |
||
| 207 | 'targetPermission' => $directoryPermission, |
||
| 208 | ], |
||
| 209 | [ |
||
| 210 | 'name' => 'labels', |
||
| 211 | 'type' => DirectoryNode::class, |
||
| 212 | 'targetPermission' => $directoryPermission, |
||
| 213 | ], |
||
| 214 | [ |
||
| 215 | 'name' => 'lock', |
||
| 216 | 'type' => DirectoryNode::class, |
||
| 217 | 'targetPermission' => $directoryPermission, |
||
| 218 | ], |
||
| 219 | ] |
||
| 220 | ] |
||
| 221 | ], |
||
| 222 | ]; |
||
| 223 | } |
||
| 224 | return $structure; |
||
| 225 | } |
||
| 386 |