d41041f01b7e748199dbe2e62c13a9d2cd7c927a
[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 /**
18 * Factory returns default folder structure object hierarchy
19 */
20 class DefaultFactory {
21
22 /**
23 * Get default structure object hierarchy
24 *
25 * @throws Exception
26 * @return RootNode
27 * @TODO: Use objectManager instead of new (will be injected)
28 */
29 public function getStructure() {
30 $rootNode = new RootNode($this->getDefaultStructureDefinition(), NULL);
31 if (!($rootNode instanceof RootNodeInterface)) {
32 throw new Exception(
33 'Root node must implement RootNodeInterface',
34 1366139176
35 );
36 }
37 $structureFacade = new StructureFacade($rootNode);
38 if (!($structureFacade instanceof StructureFacadeInterface)) {
39 throw new Exception(
40 'Structure facade must implement StructureFacadeInterface',
41 1366535827
42 );
43 }
44 return $structureFacade;
45 }
46
47 /**
48 * Default definition of folder and file structure with dynamic
49 * permission settings
50 *
51 * @return array
52 */
53 protected function getDefaultStructureDefinition() {
54 $filePermission = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'];
55 $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'];
56
57 return array(
58 // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
59 'name' => substr(PATH_site, 0, -1),
60 'targetPermission' => $directoryPermission,
61 'children' => array(
62 array(
63 'name' => 'index.php',
64 'type' => \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
65 'target' => 'typo3_src/index.php',
66 ),
67 array(
68 'name' => 'typo3',
69 'type' => \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
70 'target' => 'typo3_src/typo3',
71 ),
72 array(
73 'name' => 'typo3_src',
74 'type' => \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
75 ),
76 array(
77 'name' => 'typo3temp',
78 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
79 'targetPermission' => $directoryPermission,
80 'children' => array(
81 array(
82 'name' => 'index.html',
83 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
84 'targetPermission' => $filePermission,
85 'targetContent' => '',
86 ),
87 array(
88 'name' => 'compressor',
89 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
90 'targetPermission' => $directoryPermission,
91 ),
92 array(
93 'name' => 'cs',
94 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
95 'targetPermission' => $directoryPermission,
96 ),
97 array(
98 'name' => 'Cache',
99 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
100 'targetPermission' => $directoryPermission,
101 ),
102 array(
103 'name' => 'GB',
104 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
105 'targetPermission' => $directoryPermission,
106 ),
107 array(
108 'name' => 'llxml',
109 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
110 'targetPermission' => $directoryPermission,
111 ),
112 array(
113 'name' => 'locks',
114 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
115 'targetPermission' => $directoryPermission,
116 ),
117 array(
118 'name' => 'pics',
119 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
120 'targetPermission' => $directoryPermission,
121 ),
122 array(
123 'name' => 'sprites',
124 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
125 'targetPermission' => $directoryPermission,
126 ),
127 array(
128 'name' => 'temp',
129 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
130 'targetPermission' => $directoryPermission,
131 ),
132 array(
133 'name' => '_processed_',
134 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
135 'targetPermission' => $directoryPermission,
136 ),
137 ),
138 ),
139 array(
140 'name' => 'typo3conf',
141 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
142 'targetPermission' => $directoryPermission,
143 'children' => array(
144 array(
145 'name' => 'ext',
146 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
147 'targetPermission' => $directoryPermission,
148 ),
149 array(
150 'name' => 'l10n',
151 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
152 'targetPermission' => $directoryPermission,
153 ),
154 ),
155 ),
156 array(
157 'name' => 'uploads',
158 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
159 'targetPermission' => $directoryPermission,
160 'children' => array(
161 array(
162 'name' => 'index.html',
163 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
164 'targetPermission' => $filePermission,
165 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/uploads-index.html',
166 ),
167 array(
168 'name' => 'media',
169 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
170 'targetPermission' => $directoryPermission,
171 'children' => array(
172 array(
173 'name' => 'index.html',
174 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
175 'targetPermission' => $filePermission,
176 'targetContent' => '',
177 ),
178 ),
179 ),
180 array(
181 'name' => 'pics',
182 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
183 'targetPermission' => $directoryPermission,
184 'children' => array(
185 array(
186 'name' => 'index.html',
187 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
188 'targetPermission' => $filePermission,
189 'targetContent' => '',
190 ),
191 ),
192 ),
193 array(
194 'name' => 'tf',
195 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
196 'targetPermission' => $directoryPermission,
197 'children' => array(
198 array(
199 'name' => 'index.html',
200 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
201 'targetPermission' => $filePermission,
202 'targetContent' => '',
203 ),
204 ),
205 ),
206 ),
207 ),
208 array(
209 'name' => !empty($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) ? rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') : 'fileadmin',
210 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
211 'targetPermission' => $directoryPermission,
212 'children' => array(
213 array(
214 'name' => '_temp_',
215 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
216 'targetPermission' => $directoryPermission,
217 'children' => array(
218 array(
219 'name' => '.htaccess',
220 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
221 'targetPermission' => $filePermission,
222 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
223 ),
224 array(
225 'name' => 'index.html',
226 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
227 'targetPermission' => $filePermission,
228 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
229 ),
230 ),
231 ),
232 array(
233 'name' => 'user_upload',
234 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
235 'targetPermission' => $directoryPermission,
236 'children' => array(
237 array(
238 'name' => '_temp_',
239 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
240 'targetPermission' => $directoryPermission,
241 'children' => array(
242 array(
243 'name' => 'index.html',
244 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
245 'targetPermission' => $filePermission,
246 'targetContent' => '',
247 ),
248 array(
249 'name' => 'importexport',
250 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
251 'targetPermission' => $directoryPermission,
252 'children' => array(
253 array(
254 'name' => '.htaccess',
255 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
256 'targetPermission' => $filePermission,
257 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
258 ),
259 array(
260 'name' => 'index.html',
261 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
262 'targetPermission' => $filePermission,
263 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
264 ),
265 ),
266 ),
267 ),
268 ),
269 array(
270 'name' => 'index.html',
271 'type' => \TYPO3\CMS\Install\FolderStructure\FileNode::class,
272 'targetPermission' => $filePermission,
273 'targetContent' => '',
274 ),
275 ),
276 ),
277 ),
278 ),
279 ),
280 );
281 }
282
283 }