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