[TASK] Add more fixers for php-cs-fixer
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / FolderStructure / DefaultFactory.php
1 <?php
2 namespace TYPO3\CMS\Install\FolderStructure;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Core\Bootstrap;
18
19 /**
20 * Factory returns default folder structure object hierarchy
21 */
22 class DefaultFactory
23 {
24 /**
25 * Get default structure object hierarchy
26 *
27 * @return StructureFacadeInterface
28 */
29 public function getStructure()
30 {
31 $rootNode = new RootNode($this->getDefaultStructureDefinition(), null);
32 $structureFacade = new StructureFacade($rootNode);
33 return $structureFacade;
34 }
35
36 /**
37 * Default definition of folder and file structure with dynamic
38 * permission settings
39 *
40 * @return array
41 */
42 protected function getDefaultStructureDefinition()
43 {
44 $filePermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'];
45 $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'];
46
47 if (Bootstrap::usesComposerClassLoading()) {
48 // In composer mode the links are configurable and might even be actual files
49 // Ignore this structure in this case
50 $structureAdditional = [];
51 } else {
52 $structureAdditional = [
53 [
54 'name' => 'index.php',
55 'type' => LinkNode::class,
56 'target' => 'typo3_src/index.php',
57 ],
58 [
59 'name' => 'typo3',
60 'type' => LinkNode::class,
61 'target' => 'typo3_src/typo3',
62 ],
63 [
64 'name' => 'typo3_src',
65 'type' => LinkNode::class,
66 ],
67 ];
68 }
69 $structureBase = [
70 [
71 'name' => 'typo3temp',
72 'type' => DirectoryNode::class,
73 'targetPermission' => $directoryPermission,
74 'children' => [
75 [
76 'name' => 'index.html',
77 'type' => FileNode::class,
78 'targetPermission' => $filePermission,
79 'targetContent' => '',
80 ],
81 [
82 'name' => 'assets',
83 'type' => DirectoryNode::class,
84 'targetPermission' => $directoryPermission,
85 'children' => [
86 [
87 'name' => 'compressed',
88 'type' => DirectoryNode::class,
89 'targetPermission' => $directoryPermission
90 ],
91 [
92 'name' => 'css',
93 'type' => DirectoryNode::class,
94 'targetPermission' => $directoryPermission
95 ],
96 [
97 'name' => 'js',
98 'type' => DirectoryNode::class,
99 'targetPermission' => $directoryPermission
100 ],
101 [
102 'name' => 'images',
103 'type' => DirectoryNode::class,
104 'targetPermission' => $directoryPermission
105 ],
106 [
107 'name' => '_processed_',
108 'type' => DirectoryNode::class,
109 'targetPermission' => $directoryPermission
110 ]
111 ]
112 ],
113 [
114 'name' => 'var',
115 'type' => DirectoryNode::class,
116 'targetPermission' => $directoryPermission,
117 'children' => [
118 [
119 'name' => '.htaccess',
120 'type' => FileNode::class,
121 'targetPermission' => $filePermission,
122 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess',
123 ],
124 [
125 'name' => 'charset',
126 'type' => DirectoryNode::class,
127 'targetPermission' => $directoryPermission,
128 ],
129 [
130 'name' => 'Cache',
131 'type' => DirectoryNode::class,
132 'targetPermission' => $directoryPermission,
133 ],
134 [
135 'name' => 'locks',
136 'type' => DirectoryNode::class,
137 'targetPermission' => $directoryPermission,
138 ]
139 ]
140 ],
141 ],
142 ],
143 [
144 'name' => 'typo3conf',
145 'type' => DirectoryNode::class,
146 'targetPermission' => $directoryPermission,
147 'children' => [
148 [
149 'name' => 'ext',
150 'type' => DirectoryNode::class,
151 'targetPermission' => $directoryPermission,
152 ],
153 [
154 'name' => 'l10n',
155 'type' => DirectoryNode::class,
156 'targetPermission' => $directoryPermission,
157 ],
158 ],
159 ],
160 [
161 'name' => 'uploads',
162 'type' => DirectoryNode::class,
163 'targetPermission' => $directoryPermission,
164 'children' => [
165 [
166 'name' => 'index.html',
167 'type' => FileNode::class,
168 'targetPermission' => $filePermission,
169 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/uploads-index.html',
170 ],
171 [
172 'name' => 'media',
173 'type' => DirectoryNode::class,
174 'targetPermission' => $directoryPermission,
175 'children' => [
176 [
177 'name' => 'index.html',
178 'type' => FileNode::class,
179 'targetPermission' => $filePermission,
180 'targetContent' => '',
181 ],
182 ],
183 ],
184 ],
185 ],
186 [
187 'name' => !empty($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) ? rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') : 'fileadmin',
188 'type' => DirectoryNode::class,
189 'targetPermission' => $directoryPermission,
190 'children' => [
191 [
192 'name' => '_temp_',
193 'type' => DirectoryNode::class,
194 'targetPermission' => $directoryPermission,
195 'children' => [
196 [
197 'name' => '.htaccess',
198 'type' => FileNode::class,
199 'targetPermission' => $filePermission,
200 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
201 ],
202 [
203 'name' => 'index.html',
204 'type' => FileNode::class,
205 'targetPermission' => $filePermission,
206 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
207 ],
208 ],
209 ],
210 [
211 'name' => 'user_upload',
212 'type' => DirectoryNode::class,
213 'targetPermission' => $directoryPermission,
214 'children' => [
215 [
216 'name' => '_temp_',
217 'type' => DirectoryNode::class,
218 'targetPermission' => $directoryPermission,
219 'children' => [
220 [
221 'name' => 'index.html',
222 'type' => FileNode::class,
223 'targetPermission' => $filePermission,
224 'targetContent' => '',
225 ],
226 [
227 'name' => 'importexport',
228 'type' => DirectoryNode::class,
229 'targetPermission' => $directoryPermission,
230 'children' => [
231 [
232 'name' => '.htaccess',
233 'type' => FileNode::class,
234 'targetPermission' => $filePermission,
235 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
236 ],
237 [
238 'name' => 'index.html',
239 'type' => FileNode::class,
240 'targetPermission' => $filePermission,
241 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
242 ],
243 ],
244 ],
245 ],
246 ],
247 [
248 'name' => 'index.html',
249 'type' => FileNode::class,
250 'targetPermission' => $filePermission,
251 'targetContent' => '',
252 ],
253 ],
254 ],
255 ],
256 ],
257 ];
258
259 return [
260 // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
261 'name' => substr(PATH_site, 0, -1),
262 'targetPermission' => $directoryPermission,
263 'children' => array_merge($structureAdditional, $structureBase)
264 ];
265 }
266 }