76c9c074666088f6fa0db64dbeb6ef368c6c7095
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Core / Bootstrap.php
1 <?php
2 namespace TYPO3\CMS\Core\Core;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012-2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 require 'SystemEnvironmentBuilder.php';
31
32 /**
33 * This class encapsulates bootstrap related methods.
34 * It is required directly as the very first thing in entry scripts and
35 * used to define all base things like constants and pathes and so on.
36 *
37 * Most methods in this class have dependencies to each other. They can
38 * not be called in arbitrary order. The methods are ordered top down, so
39 * a method at the beginning has lower dependencies than a method further
40 * down. Do not fiddle with the load order in own scripts except you know
41 * exactly what you are doing!
42 *
43 * @author Christian Kuhn <lolli@schwarzbu.ch>
44 */
45 class Bootstrap {
46
47 /**
48 * @var \TYPO3\CMS\Core\Core\Bootstrap
49 */
50 static protected $instance = NULL;
51
52 /**
53 * Unique Request ID
54 *
55 * @var string
56 */
57 protected $requestId;
58
59 /**
60 * Disable direct creation of this object.
61 */
62 protected function __construct() {
63 $this->requestId = uniqid();
64 }
65
66 /**
67 * Disable direct cloning of this object.
68 */
69 protected function __clone() {
70
71 }
72
73 /**
74 * Return 'this' as singleton
75 *
76 * @return \TYPO3\CMS\Core\Core\Bootstrap
77 * @internal This is not a public API method, do not use in own extensions
78 */
79 static public function getInstance() {
80 if (is_null(self::$instance)) {
81 self::$instance = new \TYPO3\CMS\Core\Core\Bootstrap();
82 }
83 return self::$instance;
84 }
85
86 /**
87 * Gets the request's unique ID
88 *
89 * @return string Unique request ID
90 * @internal This is not a public API method, do not use in own extensions
91 */
92 public function getRequestId() {
93 return $this->requestId;
94 }
95
96 /**
97 * Prevent any unwanted output that may corrupt AJAX/compression.
98 * This does not interfere with "die()" or "echo"+"exit()" messages!
99 *
100 * @return \TYPO3\CMS\Core\Core\Bootstrap
101 * @internal This is not a public API method, do not use in own extensions
102 */
103 public function startOutputBuffering() {
104 ob_start();
105 return $this;
106 }
107
108 /**
109 * Run the base setup that checks server environment,
110 * determines pathes, populates base files and sets common configuration.
111 *
112 * Script execution will be aborted if something fails here.
113 *
114 * @param string $relativePathPart Relative path of the entry script back to document root
115 * @return \TYPO3\CMS\Core\Core\Bootstrap
116 * @internal This is not a public API method, do not use in own extensions
117 */
118 public function baseSetup($relativePathPart = '') {
119 \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run($relativePathPart);
120 return $this;
121 }
122
123 /**
124 * Includes LocalConfiguration.php and sets several
125 * global settings depending on configuration.
126 *
127 * @return \TYPO3\CMS\Core\Core\Bootstrap
128 * @internal This is not a public API method, do not use in own extensions
129 */
130 public function loadConfigurationAndInitialize() {
131 $this->getInstance()
132 ->populateLocalConfiguration()
133 ->registerExtDirectComponents()
134 ->initializeCachingFramework()
135 ->registerAutoloader()
136 ->checkUtf8DatabaseSettingsOrDie()
137 ->transferDeprecatedCurlSettings()
138 ->setCacheHashOptions()
139 ->enforceCorrectProxyAuthScheme()
140 ->setDefaultTimezone()
141 ->initializeL10nLocales()
142 ->configureImageProcessingOptions()
143 ->convertPageNotFoundHandlingToBoolean()
144 ->registerGlobalDebugFunctions()
145 ->registerSwiftMailer()
146 ->configureExceptionHandling()
147 ->setMemoryLimit()
148 ->defineTypo3RequestTypes();
149 return $this;
150 }
151
152 /**
153 * Load TYPO3_LOADED_EXT and ext_localconf
154 *
155 * @param boolean $allowCaching
156 * @return \TYPO3\CMS\Core\Core\Bootstrap
157 * @internal This is not a public API method, do not use in own extensions
158 */
159 public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = TRUE) {
160 $this->getInstance()
161 ->populateTypo3LoadedExtGlobal($allowCaching)
162 ->loadAdditionalConfigurationFromExtensions($allowCaching);
163 return $this;
164 }
165
166 /**
167 * Load TYPO3_LOADED_EXT, recreate class loader registry and load ext_localconf
168 *
169 * @param boolean $allowCaching
170 * @return \TYPO3\CMS\Core\Core\Bootstrap
171 * @internal This is not a public API method, do not use in own extensions
172 */
173 public function reloadTypo3LoadedExtAndClassLoaderAndExtLocalconf() {
174 $bootstrap = $this->getInstance();
175 $bootstrap->populateTypo3LoadedExtGlobal(FALSE);
176 \TYPO3\CMS\Core\Core\ClassLoader::loadClassLoaderCache();
177 $bootstrap->loadAdditionalConfigurationFromExtensions(FALSE);
178 return $this;
179 }
180
181 /**
182 * Sets up additional configuration applied in all scopes
183 *
184 * @return \TYPO3\CMS\Core\Core\Bootstrap
185 * @internal This is not a public API method, do not use in own extensions
186 */
187 public function applyAdditionalConfigurationSettings() {
188 $this->getInstance()
189 ->deprecationLogForOldExtCacheSetting()
190 ->initializeExceptionHandling()
191 ->setFinalCachingFrameworkCacheConfiguration()
192 ->defineLoggingAndExceptionConstants()
193 ->unsetReservedGlobalVariables();
194 return $this;
195 }
196
197 /**
198 * Throws an exception if no browser could be identified
199 *
200 * @return \TYPO3\CMS\Core\Core\Bootstrap
201 * @throws \RuntimeException
202 * @internal This is not a public API method, do not use in own extensions
203 */
204 public function checkValidBrowserOrDie() {
205 // Checks for proper browser
206 if (empty($GLOBALS['CLIENT']['BROWSER'])) {
207 throw new \RuntimeException('Browser Error: Your browser version looks incompatible with this TYPO3 version!', 1294587023);
208 }
209 return $this;
210 }
211
212 /**
213 * Populate the local configuration.
214 * Merge default TYPO3_CONF_VARS with content of typo3conf/LocalConfiguration.php,
215 * execute typo3conf/AdditionalConfiguration.php, define database related constants.
216 *
217 * @return \TYPO3\CMS\Core\Core\Bootstrap
218 */
219 protected function populateLocalConfiguration() {
220 try {
221 // We need an early instance of the configuration manager.
222 // Since makeInstance relies on the object configuration, we create it here with new instead
223 // and register it as singleton instance for later use.
224 $configuarationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
225 \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager', $configuarationManager);
226 $configuarationManager->exportConfiguration();
227 } catch (\Exception $e) {
228 die($e->getMessage());
229 }
230 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
231 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
232 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
233 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
234 define('TYPO3_extTableDef_script',
235 isset($GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript'])
236 ? $GLOBALS['TYPO3_CONF_VARS']['DB']['extTablesDefinitionScript']
237 : 'extTables.php');
238 unset($GLOBALS['TYPO3_CONF_VARS']['DB']);
239 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
240 return $this;
241 }
242
243 /**
244 * Register default ExtDirect components
245 *
246 * @return \TYPO3\CMS\Core\Core\Bootstrap
247 */
248 protected function registerExtDirectComponents() {
249 if (TYPO3_MODE === 'BE') {
250 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.DataProvider', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeDataProvider', 'web', 'user,group');
251 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.Commands', 'TYPO3\\CMS\\Backend\\Tree\\Pagetree\\ExtdirectTreeCommands', 'web', 'user,group');
252 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.PageTree.ContextMenuDataProvider', 'TYPO3\\CMS\\Backend\\ContextMenu\\Pagetree\\Extdirect\\ContextMenuConfiguration', 'web', 'user,group');
253 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.LiveSearchActions.ExtDirect', 'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider', 'web_list', 'user,group');
254 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.BackendUserSettings.ExtDirect', 'TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
255 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.CSH.ExtDirect', 'TYPO3\\CMS\\ContextHelp\\ExtDirect\\ContextHelpDataProvider');
256 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.ExtDirectStateProvider.ExtDirect', 'TYPO3\\CMS\\Backend\\InterfaceState\\ExtDirect\\DataProvider');
257 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Components.DragAndDrop.CommandController',
258 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('backend') . 'Classes/View/PageLayout/Extdirect/ExtdirectPageCommands.php:TYPO3\\CMS\\Backend\\View\\PageLayout\\ExtDirect\\ExtdirectPageCommands', 'web', 'user,group');
259 }
260 return $this;
261 }
262
263 /**
264 * Redirect to install tool if database host and database are not defined
265 *
266 * @return \TYPO3\CMS\Core\Core\Bootstrap
267 * @internal This is not a public API method, do not use in own extensions
268 */
269 public function redirectToInstallToolIfDatabaseCredentialsAreMissing() {
270 if (!TYPO3_db_host && !TYPO3_db) {
271 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('install/index.php?mode=123&step=1&password=joh316');
272 }
273 return $this;
274 }
275
276 /**
277 * Initialize caching framework
278 *
279 * @return \TYPO3\CMS\Core\Core\Bootstrap
280 */
281 protected function initializeCachingFramework() {
282 \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework();
283 return $this;
284 }
285
286 /**
287 * Register autoloader
288 *
289 * @return \TYPO3\CMS\Core\Core\Bootstrap
290 */
291 protected function registerAutoloader() {
292 if (PHP_VERSION_ID < 50307) {
293 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307::registerAutoloader();
294 } else {
295 \TYPO3\CMS\Core\Core\ClassLoader::registerAutoloader();
296 }
297 return $this;
298 }
299
300 /**
301 * Checking for UTF-8 in the settings since TYPO3 4.5
302 *
303 * Since TYPO3 4.5, everything other than UTF-8 is deprecated.
304 *
305 * [BE][forceCharset] is set to the charset that TYPO3 is using
306 * [SYS][setDBinit] is used to set the DB connection
307 * and both settings need to be adjusted for UTF-8 in order to work properly
308 *
309 * @return \TYPO3\CMS\Core\Core\Bootstrap
310 */
311 protected function checkUtf8DatabaseSettingsOrDie() {
312 // Check if [BE][forceCharset] has been set in localconf.php
313 if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])) {
314 // die() unless we're already on UTF-8
315 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != 'utf-8' &&
316 $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] &&
317 TYPO3_enterInstallScript !== '1') {
318
319 die('This installation was just upgraded to a new TYPO3 version. Since TYPO3 4.7, utf-8 is always enforced.<br />' .
320 'The configuration option $GLOBALS[\'TYPO3_CONF_VARS\'][BE][forceCharset] was marked as deprecated in TYPO3 4.5 and is now ignored.<br />' .
321 'You have configured the value to something different, which is not supported anymore.<br />' .
322 'Please proceed to the Update Wizard in the TYPO3 Install Tool to update your configuration.'
323 );
324 } else {
325 unset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
326 }
327 }
328
329 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) &&
330 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] !== '-1' &&
331 preg_match('/SET NAMES [\'"]?utf8[\'"]?/i', $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) === FALSE &&
332 TYPO3_enterInstallScript !== '1') {
333
334 // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
335 die('This TYPO3 installation is using the $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'setDBinit\'] property with the following value:' . chr(10) .
336 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] . chr(10) . chr(10) .
337 'It looks like UTF-8 is not used for this connection.' . chr(10) . chr(10) .
338 'Everything other than UTF-8 is unsupported since TYPO3 4.7.' . chr(10) .
339 'The DB, its connection and TYPO3 should be migrated to UTF-8 therefore. Please check your setup.'
340 );
341 } else {
342 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] = 'SET NAMES utf8;';
343 }
344 return $this;
345 }
346
347 /**
348 * Parse old curl options and set new http ones instead
349 *
350 * @TODO : This code segment must still be finished
351 * @return \TYPO3\CMS\Core\Core\Bootstrap
352 */
353 protected function transferDeprecatedCurlSettings() {
354 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
355 $proxyParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
356 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
357 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
358 }
359 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
360 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
361 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
362 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
363 }
364 return $this;
365 }
366
367 /**
368 * Set cacheHash options
369 *
370 * @return \TYPO3\CMS\Core\Core\Bootstrap
371 */
372 protected function setCacheHashOptions() {
373 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
374 'cachedParametersWhiteList' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
375 'excludedParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
376 'requireCacheHashPresenceParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
377 );
378 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
379 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
380 } else {
381 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
382 }
383 return $this;
384 }
385
386 /**
387 * $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] must be either
388 * 'digest' or 'basic' with fallback to 'basic'
389 *
390 * @return \TYPO3\CMS\Core\Core\Bootstrap
391 */
392 protected function enforceCorrectProxyAuthScheme() {
393 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] === 'digest' ?: ($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] = 'basic');
394 return $this;
395 }
396
397 /**
398 * Set default timezone
399 *
400 * @return \TYPO3\CMS\Core\Core\Bootstrap
401 */
402 protected function setDefaultTimezone() {
403 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
404 if (empty($timeZone)) {
405 // Time zone from the server environment (TZ env or OS query)
406 $defaultTimeZone = @date_default_timezone_get();
407 if ($defaultTimeZone !== '') {
408 $timeZone = $defaultTimeZone;
409 } else {
410 $timeZone = 'UTC';
411 }
412 }
413 // Set default to avoid E_WARNINGs with PHP > 5.3
414 date_default_timezone_set($timeZone);
415 return $this;
416 }
417
418 /**
419 * Initialize the locales handled by TYPO3
420 *
421 * @return \TYPO3\CMS\Core\Core\Bootstrap
422 */
423 protected function initializeL10nLocales() {
424 \TYPO3\CMS\Core\Localization\Locales::initialize();
425 return $this;
426 }
427
428 /**
429 * Based on the configuration of the image processing some options are forced
430 * to simplify configuration settings and combinations
431 *
432 * @return \TYPO3\CMS\Core\Core\Bootstrap
433 */
434 protected function configureImageProcessingOptions() {
435 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) {
436 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] = 0;
437 $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = 0;
438 }
439 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
440 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] = '';
441 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] = '';
442 $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] = 'gif,jpg,jpeg,png';
443 $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] = 0;
444 }
445 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) {
446 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 1;
447 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
448 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'] = 1;
449 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
450 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 0;
451 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'] = 0;
452 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
453 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'] = -1;
454 }
455 }
456 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState']) {
457 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? 0 : 1;
458 }
459 return $this;
460 }
461
462 /**
463 * Convert type of "pageNotFound_handling" setting in case it was written as a
464 * string (e.g. if edited in Install Tool)
465 *
466 * @TODO : Remove, if the Install Tool handles such data types correctly
467 * @return \TYPO3\CMS\Core\Core\Bootstrap
468 */
469 protected function convertPageNotFoundHandlingToBoolean() {
470 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
471 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
472 }
473 return $this;
474 }
475
476 /**
477 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
478 *
479 * Note: Yes, this is possible in php! xdebug() is then a global function, even
480 * if registerGlobalDebugFunctions() is encapsulated in class scope.
481 *
482 * @return \TYPO3\CMS\Core\Core\Bootstrap
483 */
484 protected function registerGlobalDebugFunctions() {
485 require_once('GlobalDebugFunctions.php');
486 return $this;
487 }
488
489 /**
490 * Mail sending via Swift Mailer
491 *
492 * @return \TYPO3\CMS\Core\Core\Bootstrap
493 */
494 protected function registerSwiftMailer() {
495 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] = 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
496 return $this;
497 }
498
499 /**
500 * Configure and set up exception and error handling
501 *
502 * @return \TYPO3\CMS\Core\Core\Bootstrap
503 */
504 protected function configureExceptionHandling() {
505 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
506 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
507 // Turn error logging on/off.
508 if (($displayErrors = intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'])) != '-1') {
509 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
510 if ($displayErrors == 2) {
511 if (\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
512 $displayErrors = 1;
513 } else {
514 $displayErrors = 0;
515 }
516 }
517 if ($displayErrors == 0) {
518 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
519 }
520 if ($displayErrors == 1) {
521 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
522 define('TYPO3_ERRORHANDLER_MODE', 'debug');
523 }
524 @ini_set('display_errors', $displayErrors);
525 } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
526 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
527 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
528 }
529 return $this;
530 }
531
532 /**
533 * Set PHP memory limit depending on value of
534 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
535 *
536 * @return \TYPO3\CMS\Core\Core\Bootstrap
537 */
538 protected function setMemoryLimit() {
539 if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
540 @ini_set('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
541 }
542 return $this;
543 }
544
545 /**
546 * Define TYPO3_REQUESTTYPE* constants
547 * so devs exactly know what type of request it is
548 *
549 * @return \TYPO3\CMS\Core\Core\Bootstrap
550 */
551 protected function defineTypo3RequestTypes() {
552 define('TYPO3_REQUESTTYPE_FE', 1);
553 define('TYPO3_REQUESTTYPE_BE', 2);
554 define('TYPO3_REQUESTTYPE_CLI', 4);
555 define('TYPO3_REQUESTTYPE_AJAX', 8);
556 define('TYPO3_REQUESTTYPE_INSTALL', 16);
557 define('TYPO3_REQUESTTYPE', (TYPO3_MODE == 'FE' ? TYPO3_REQUESTTYPE_FE : 0) | (TYPO3_MODE == 'BE' ? TYPO3_REQUESTTYPE_BE : 0) | (defined('TYPO3_cliMode') && TYPO3_cliMode ? TYPO3_REQUESTTYPE_CLI : 0) | (defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript ? TYPO3_REQUESTTYPE_INSTALL : 0) | ($GLOBALS['TYPO3_AJAX'] ? TYPO3_REQUESTTYPE_AJAX : 0));
558 return $this;
559 }
560
561 /**
562 * Set up $GLOBALS['TYPO3_LOADED_EXT'] array with basic information
563 * about extensions.
564 *
565 * @param boolean $allowCaching
566 * @return \TYPO3\CMS\Core\Core\Bootstrap
567 */
568 protected function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
569 $GLOBALS['TYPO3_LOADED_EXT'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadTypo3LoadedExtensionInformation($allowCaching);
570 return $this;
571 }
572
573 /**
574 * Load extension configuration files (ext_localconf.php)
575 *
576 * The ext_localconf.php files in extensions are meant to make changes
577 * to the global $TYPO3_CONF_VARS configuration array.
578 *
579 * @param boolean $allowCaching
580 * @return \TYPO3\CMS\Core\Core\Bootstrap
581 */
582 protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
583 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
584 return $this;
585 }
586
587 /**
588 * Write deprecation log if deprecated extCache setting was set in the instance.
589 *
590 * @return \TYPO3\CMS\Core\Core\Bootstrap
591 * @deprecated since 6.0, the check will be removed two version later.
592 */
593 protected function deprecationLogForOldExtCacheSetting() {
594 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] !== -1) {
595 \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Setting $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'extCache\'] is unused and can be removed from localconf.php');
596 }
597 return $this;
598 }
599
600 /**
601 * Initialize exception handling
602 *
603 * @return \TYPO3\CMS\Core\Core\Bootstrap
604 */
605 protected function initializeExceptionHandling() {
606 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
607 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== '') {
608 // Register an error handler for the given errorHandlerErrors
609 $errorHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
610 // Set errors which will be converted in an exception
611 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
612 }
613 // Instantiate the exception handler once to make sure object is registered
614 // @TODO: Figure out if this is really needed
615 \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
616 }
617 return $this;
618 }
619
620 /**
621 * Extensions may register new caches, so we set the
622 * global cache array to the manager again at this point
623 *
624 * @return \TYPO3\CMS\Core\Core\Bootstrap
625 */
626 protected function setFinalCachingFrameworkCacheConfiguration() {
627 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
628 return $this;
629 }
630
631 /**
632 * Define logging and exception constants
633 *
634 * @return \TYPO3\CMS\Core\Core\Bootstrap
635 */
636 protected function defineLoggingAndExceptionConstants() {
637 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
638 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
639 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
640 return $this;
641 }
642
643 /**
644 * Unsetting reserved global variables:
645 * Those are set in "ext:core/ext_tables.php" file:
646 *
647 * @return \TYPO3\CMS\Core\Core\Bootstrap
648 */
649 protected function unsetReservedGlobalVariables() {
650 unset($GLOBALS['PAGES_TYPES']);
651 unset($GLOBALS['TCA']);
652 unset($GLOBALS['TBE_MODULES']);
653 unset($GLOBALS['TBE_STYLES']);
654 unset($GLOBALS['FILEICONS']);
655 // Those set in init.php:
656 unset($GLOBALS['WEBMOUNTS']);
657 unset($GLOBALS['FILEMOUNTS']);
658 unset($GLOBALS['BE_USER']);
659 // Those set otherwise:
660 unset($GLOBALS['TBE_MODULES_EXT']);
661 unset($GLOBALS['TCA_DESCR']);
662 unset($GLOBALS['LOCAL_LANG']);
663 unset($GLOBALS['TYPO3_AJAX']);
664 return $this;
665 }
666
667 /**
668 * Initialize t3lib_db in $GLOBALS and connect if requested
669 *
670 * @param boolean $connect Whether db should be connected
671 * @return \TYPO3\CMS\Core\Core\Bootstrap
672 * @internal This is not a public API method, do not use in own extensions
673 */
674 public function initializeTypo3DbGlobal($connect = TRUE) {
675 /** @var TYPO3_DB TYPO3\CMS\Core\Database\DatabaseConnection */
676 $GLOBALS['TYPO3_DB'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
677 $GLOBALS['TYPO3_DB']->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
678 if ($connect) {
679 $this->establishDatabaseConnection();
680 }
681 return $this;
682 }
683
684 /**
685 * Check adminOnly configuration variable and redirects
686 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
687 *
688 * @throws \RuntimeException
689 * @return \TYPO3\CMS\Core\Core\Bootstrap
690 * @internal This is not a public API method, do not use in own extensions
691 */
692 public function checkLockedBackendAndRedirectOrDie() {
693 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
694 throw new \RuntimeException('TYPO3 Backend locked: Backend and Install Tool are locked for maintenance. [BE][adminOnly] is set to "' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly']) . '".', 1294586847);
695 }
696 if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
697 if (TYPO3_PROCEED_IF_NO_USER === 2) {
698
699 } else {
700 $fileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
701 if ($fileContent) {
702 header('Location: ' . $fileContent);
703 } else {
704 throw new \RuntimeException('TYPO3 Backend locked: Browser backend is locked for maintenance. Remove lock by removing the file "typo3conf/LOCK_BACKEND" or use CLI-scripts.', 1294586848);
705 }
706 die;
707 }
708 }
709 return $this;
710 }
711
712 /**
713 * Compare client IP with IPmaskList and exit the script run
714 * if the client is not allowed to access the backend
715 *
716 * @return \TYPO3\CMS\Core\Core\Bootstrap
717 * @internal This is not a public API method, do not use in own extensions
718 */
719 public function checkBackendIpOrDie() {
720 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
721 if (!\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
722 // Send Not Found header - if the webserver can make use of it
723 header('Status: 404 Not Found');
724 // Just point us away from here...
725 header('Location: http://');
726 // ... and exit good!
727 die;
728 }
729 }
730 return $this;
731 }
732
733 /**
734 * Check lockSSL configuration variable and redirect
735 * to https version of the backend if needed
736 *
737 * @return \TYPO3\CMS\Core\Core\Bootstrap
738 * @internal This is not a public API method, do not use in own extensions
739 */
740 public function checkSslBackendAndRedirectIfNeeded() {
741 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
742 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'])) {
743 $sslPortSuffix = ':' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']);
744 } else {
745 $sslPortSuffix = '';
746 }
747 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
748 $requestStr = substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir));
749 if ($requestStr === 'index.php' && !\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
750 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 2);
751 list($server, $address) = explode('/', $url, 2);
752 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
753 die;
754 }
755 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
756 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) === 2) {
757 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
758 list($server, $address) = explode('/', $url, 2);
759 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
760 } else {
761 // Send Not Found header - if the webserver can make use of it...
762 header('Status: 404 Not Found');
763 // Just point us away from here...
764 header('Location: http://');
765 }
766 // ... and exit good!
767 die;
768 }
769 }
770 return $this;
771 }
772
773 /**
774 * Establish connection to the database
775 *
776 * @return \TYPO3\CMS\Core\Core\Bootstrap
777 * @internal This is not a public API method, do not use in own extensions
778 */
779 public function establishDatabaseConnection() {
780 $GLOBALS['TYPO3_DB']->connectDB();
781 return $this;
782 }
783
784 /**
785 * Load TCA for frontend
786 *
787 * This method is *only* executed in frontend scope. The idea is to execute the
788 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
789 * and then cache the full TCA on disk to be used for the next run again.
790 *
791 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
792 * is still always there.
793 *
794 * @return \TYPO3\CMS\Core\Core\Bootstrap
795 * @internal This is not a public API method, do not use in own extensions
796 */
797 public function loadCachedTca() {
798 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
799 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
800 $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
801 if ($codeCache->has($cacheIdentifier)) {
802 $codeCache->requireOnce($cacheIdentifier);
803 } else {
804 $this->loadExtensionTables(TRUE);
805 $phpCodeToCache = '$GLOBALS[\'TCA\'] = ';
806 $phpCodeToCache .= \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($GLOBALS['TCA']);
807 $phpCodeToCache .= ';';
808 $codeCache->set($cacheIdentifier, $phpCodeToCache);
809 }
810 return $this;
811 }
812
813 /**
814 * Load ext_tables and friends.
815 *
816 * This will mainly set up $TCA and several other global arrays
817 * through API's like extMgm.
818 * Executes ext_tables.php files of loaded extensions or the
819 * according cache file if exists.
820 *
821 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
822 * @return \TYPO3\CMS\Core\Core\Bootstrap
823 * @internal This is not a public API method, do not use in own extensions
824 */
825 public function loadExtensionTables($allowCaching = TRUE) {
826 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
827 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
828 $this->executeExtTablesAdditionalFile();
829 $this->runExtTablesPostProcessingHooks();
830 return $this;
831 }
832
833 /**
834 * Execute TYPO3_extTableDef_script if defined and exists
835 *
836 * Note: For backwards compatibility some global variables are
837 * explicitly set as global to be used without $GLOBALS[] in
838 * the extension table script. It is discouraged to access variables like
839 * $TBE_MODULES directly, but we can not prohibit
840 * this without heavily breaking backwards compatibility.
841 *
842 * @TODO : We could write a scheduler / reports module or an update checker
843 * @TODO : It should be defined, which global arrays are ok to be manipulated
844 *
845 * @return void
846 */
847 protected function executeExtTablesAdditionalFile() {
848 // It is discouraged to use those global variables directly, but we
849 // can not prohibit this without breaking backwards compatibility
850 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
851 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
852 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
853 global $_EXTKEY;
854 // Load additional ext tables script if the file exists
855 $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
856 if (file_exists($extTablesFile) && is_file($extTablesFile)) {
857 include $extTablesFile;
858 }
859 }
860
861 /**
862 * Check for registered ext tables hooks and run them
863 *
864 * @throws \UnexpectedValueException
865 * @return void
866 */
867 protected function runExtTablesPostProcessingHooks() {
868 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
869 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
870 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
871 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classReference);
872 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
873 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
874 }
875 $hookObject->processData();
876 }
877 }
878 }
879
880 /**
881 * Initialize sprite manager
882 *
883 * @return \TYPO3\CMS\Core\Core\Bootstrap
884 * @internal This is not a public API method, do not use in own extensions
885 */
886 public function initializeSpriteManager() {
887 \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
888 return $this;
889 }
890
891 /**
892 * Initialize backend user object in globals
893 *
894 * @return \TYPO3\CMS\Core\Core\Bootstrap
895 * @internal This is not a public API method, do not use in own extensions
896 */
897 public function initializeBackendUser() {
898 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
899 $backendUser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
900 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
901 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
902 $backendUser->auth_timeout_field = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
903 $backendUser->OS = TYPO3_OS;
904 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
905 $backendUser->dontSetCookie = TRUE;
906 }
907 // The global must be available very early, because methods below
908 // might triger code which relies on it. See: #45625
909 $GLOBALS['BE_USER'] = $backendUser;
910 $backendUser->start();
911 $backendUser->checkCLIuser();
912 $backendUser->backendCheckLogin();
913 return $this;
914 }
915
916 /**
917 * Initialize backend user mount points
918 *
919 * @return \TYPO3\CMS\Core\Core\Bootstrap
920 * @internal This is not a public API method, do not use in own extensions
921 */
922 public function initializeBackendUserMounts() {
923 // Includes deleted mount pages as well! @TODO: Figure out why ...
924 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
925 $GLOBALS['BE_USER']->getFileStorages();
926 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->groupData['filemounts'];
927 return $this;
928 }
929
930 /**
931 * Initialize language object
932 *
933 * @return \TYPO3\CMS\Core\Core\Bootstrap
934 * @internal This is not a public API method, do not use in own extensions
935 */
936 public function initializeLanguageObject() {
937 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
938 $GLOBALS['LANG'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Lang\LanguageService');
939 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
940 return $this;
941 }
942
943 /**
944 * Throw away all output that may have happened during bootstrapping by weird extensions
945 *
946 * @return \TYPO3\CMS\Core\Core\Bootstrap
947 * @internal This is not a public API method, do not use in own extensions
948 */
949 public function endOutputBufferingAndCleanPreviousOutput() {
950 ob_clean();
951 return $this;
952 }
953
954 /**
955 * Initialize output compression if configured
956 *
957 * @return \TYPO3\CMS\Core\Core\Bootstrap
958 * @internal This is not a public API method, do not use in own extensions
959 */
960 public function initializeOutputCompression() {
961 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
962 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
963 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
964 }
965 ob_start('ob_gzhandler');
966 }
967 return $this;
968 }
969
970 /**
971 * Initialize module menu object
972 *
973 * @return \TYPO3\CMS\Core\Core\Bootstrap
974 * @internal This is not a public API method, do not use in own extensions
975 */
976 public function initializeModuleMenuObject() {
977 /** @var $moduleMenuUtility Typo3_BackendModule_Utility */
978 $moduleMenuUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleController');
979 $moduleMenuUtility->createModuleMenu();
980 return $this;
981 }
982
983 /**
984 * Things that should be performed to shut down the framework.
985 * This method is called in all important scripts for a clean
986 * shut down of the system.
987 *
988 * @return \TYPO3\CMS\Core\Core\Bootstrap
989 * @internal This is not a public API method, do not use in own extensions
990 */
991 public function shutdown() {
992 if (PHP_VERSION_ID < 50307) {
993 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307::unregisterAutoloader();
994 } else {
995 \TYPO3\CMS\Core\Core\ClassLoader::unregisterAutoloader();
996 }
997 return $this;
998 }
999
1000 /**
1001 * Provides an instance of "template" for backend-modules to
1002 * work with.
1003 *
1004 * @return \TYPO3\CMS\Core\Core\Bootstrap
1005 * @internal This is not a public API method, do not use in own extensions
1006 */
1007 public function initializeBackendTemplate() {
1008 $GLOBALS['TBE_TEMPLATE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
1009 return $this;
1010 }
1011
1012 }
1013
1014
1015 ?>