| Conditions | 6 |
| Paths | 6 |
| Total Lines | 185 |
| Code Lines | 116 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 | $structure = [ |
||
| 135 | // Note that root node has no trailing slash like all others |
||
| 136 | 'name' => Environment::getProjectPath(), |
||
| 137 | 'targetPermission' => $directoryPermission, |
||
| 138 | 'children' => [ |
||
| 139 | [ |
||
| 140 | 'name' => $publicPath, |
||
| 141 | 'type' => DirectoryNode::class, |
||
| 142 | 'targetPermission' => $directoryPermission, |
||
| 143 | 'children' => [ |
||
| 144 | [ |
||
| 145 | 'name' => 'typo3temp', |
||
| 146 | 'type' => DirectoryNode::class, |
||
| 147 | 'targetPermission' => $directoryPermission, |
||
| 148 | 'children' => [ |
||
| 149 | [ |
||
| 150 | 'name' => 'index.html', |
||
| 151 | 'type' => FileNode::class, |
||
| 152 | 'targetPermission' => $filePermission, |
||
| 153 | 'targetContent' => '', |
||
| 154 | ], |
||
| 155 | $this->getTemporaryAssetsFolderStructure(), |
||
| 156 | ], |
||
| 157 | ], |
||
| 158 | [ |
||
| 159 | 'name' => 'typo3conf', |
||
| 160 | 'type' => DirectoryNode::class, |
||
| 161 | 'targetPermission' => $directoryPermission, |
||
| 162 | 'children' => [ |
||
| 163 | [ |
||
| 164 | 'name' => 'ext', |
||
| 165 | 'type' => DirectoryNode::class, |
||
| 166 | 'targetPermission' => $directoryPermission, |
||
| 167 | ], |
||
| 168 | ], |
||
| 169 | ], |
||
| 170 | $this->getFileadminStructure(), |
||
| 171 | ] |
||
| 172 | ], |
||
| 173 | [ |
||
| 174 | 'name' => 'var', |
||
| 175 | 'type' => DirectoryNode::class, |
||
| 176 | 'targetPermission' => $directoryPermission, |
||
| 177 | 'children' => [ |
||
| 178 | [ |
||
| 179 | 'name' => '.htaccess', |
||
| 180 | 'type' => FileNode::class, |
||
| 181 | 'targetPermission' => $filePermission, |
||
| 182 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess', |
||
| 183 | ], |
||
| 184 | [ |
||
| 185 | 'name' => 'charset', |
||
| 186 | 'type' => DirectoryNode::class, |
||
| 187 | 'targetPermission' => $directoryPermission, |
||
| 188 | ], |
||
| 189 | [ |
||
| 190 | 'name' => 'cache', |
||
| 191 | 'type' => DirectoryNode::class, |
||
| 192 | 'targetPermission' => $directoryPermission, |
||
| 193 | ], |
||
| 194 | [ |
||
| 195 | 'name' => 'labels', |
||
| 196 | 'type' => DirectoryNode::class, |
||
| 197 | 'targetPermission' => $directoryPermission, |
||
| 198 | ], |
||
| 199 | [ |
||
| 200 | 'name' => 'lock', |
||
| 201 | 'type' => DirectoryNode::class, |
||
| 202 | 'targetPermission' => $directoryPermission, |
||
| 203 | ], |
||
| 204 | ] |
||
| 205 | ] |
||
| 206 | ], |
||
| 207 | ]; |
||
| 208 | |||
| 209 | // Have a default .htaccess if running apache web server or a default web.config if running IIS |
||
| 210 | if ($this->isApacheServer()) { |
||
| 211 | $structure['children'][0]['children'][] = [ |
||
| 212 | 'name' => '.htaccess', |
||
| 213 | 'type' => FileNode::class, |
||
| 214 | 'targetPermission' => $filePermission, |
||
| 215 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess', |
||
| 216 | ]; |
||
| 217 | } elseif ($this->isMicrosoftIisServer()) { |
||
| 218 | $structure['children'][0]['children'][] = [ |
||
| 219 | 'name' => 'web.config', |
||
| 220 | 'type' => FileNode::class, |
||
| 221 | 'targetPermission' => $filePermission, |
||
| 222 | 'targetContentFile' => Environment::getFrameworkBasePath() . '/install/Resources/Private/FolderStructureTemplateFiles/root-web-config', |
||
| 223 | ]; |
||
| 224 | } |
||
| 225 | } |
||
| 226 | return $structure; |
||
| 227 | } |
||
| 358 |