[TASK] Follow-up to TCA refactoring
[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 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' && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] && TYPO3_enterInstallScript !== '1') {
316 die('This installation was just upgraded to a new TYPO3 version. Since TYPO3 4.7, utf-8 is always enforced.<br />' . 'The configuration option $GLOBALS[\'TYPO3_CONF_VARS\'][BE][forceCharset] was marked as deprecated in TYPO3 4.5 and is now ignored.<br />' . 'You have configured the value to something different, which is not supported anymore.<br />' . 'Please proceed to the Update Wizard in the TYPO3 Install Tool to update your configuration.');
317 } else {
318 unset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
319 }
320 }
321 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] !== '-1' && preg_match('/SET NAMES utf8/', $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']) === FALSE && TYPO3_enterInstallScript !== '1') {
322 // Only accept "SET NAMES utf8" for this setting, otherwise die with a nice error
323 die('This TYPO3 installation is using the $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'setDBinit\'] property with the following value:' . chr(10) . $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] . chr(10) . chr(10) . 'It looks like UTF-8 is not used for this connection.' . chr(10) . chr(10) . 'Everything other than UTF-8 is unsupported since TYPO3 4.7.' . chr(10) . 'The DB, its connection and TYPO3 should be migrated to UTF-8 therefore. Please check your setup.');
324 } else {
325 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] = 'SET NAMES utf8;';
326 }
327 return $this;
328 }
329
330 /**
331 * Parse old curl options and set new http ones instead
332 *
333 * @TODO : This code segment must still be finished
334 * @return \TYPO3\CMS\Core\Core\Bootstrap
335 */
336 protected function transferDeprecatedCurlSettings() {
337 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
338 $proxyParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'], 2);
339 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
340 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
341 }
342 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])) {
343 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
344 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
345 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
346 }
347 return $this;
348 }
349
350 /**
351 * Set cacheHash options
352 *
353 * @return \TYPO3\CMS\Core\Core\Bootstrap
354 */
355 protected function setCacheHashOptions() {
356 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
357 'cachedParametersWhiteList' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
358 'excludedParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
359 'requireCacheHashPresenceParameters' => \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
360 );
361 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
362 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
363 } else {
364 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
365 }
366 return $this;
367 }
368
369 /**
370 * $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] must be either
371 * 'digest' or 'basic' with fallback to 'basic'
372 *
373 * @return \TYPO3\CMS\Core\Core\Bootstrap
374 */
375 protected function enforceCorrectProxyAuthScheme() {
376 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] === 'digest' ?: ($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_auth_scheme'] = 'basic');
377 return $this;
378 }
379
380 /**
381 * Set default timezone
382 *
383 * @return \TYPO3\CMS\Core\Core\Bootstrap
384 */
385 protected function setDefaultTimezone() {
386 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
387 if (empty($timeZone)) {
388 // Time zone from the server environment (TZ env or OS query)
389 $defaultTimeZone = @date_default_timezone_get();
390 if ($defaultTimeZone !== '') {
391 $timeZone = $defaultTimeZone;
392 } else {
393 $timeZone = 'UTC';
394 }
395 }
396 // Set default to avoid E_WARNINGs with PHP > 5.3
397 date_default_timezone_set($timeZone);
398 return $this;
399 }
400
401 /**
402 * Initialize the locales handled by TYPO3
403 *
404 * @return \TYPO3\CMS\Core\Core\Bootstrap
405 */
406 protected function initializeL10nLocales() {
407 \TYPO3\CMS\Core\Localization\Locales::initialize();
408 return $this;
409 }
410
411 /**
412 * Based on the configuration of the image processing some options are forced
413 * to simplify configuration settings and combinations
414 *
415 * @return \TYPO3\CMS\Core\Core\Bootstrap
416 */
417 protected function configureImageProcessingOptions() {
418 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) {
419 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] = 0;
420 $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = 0;
421 }
422 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
423 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] = '';
424 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] = '';
425 $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] = 'gif,jpg,jpeg,png';
426 $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] = 0;
427 }
428 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) {
429 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 1;
430 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
431 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'] = 1;
432 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
433 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 0;
434 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'] = 0;
435 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_no_effects'] = 1;
436 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'] = -1;
437 }
438 }
439 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState']) {
440 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? 0 : 1;
441 }
442 return $this;
443 }
444
445 /**
446 * Convert type of "pageNotFound_handling" setting in case it was written as a
447 * string (e.g. if edited in Install Tool)
448 *
449 * @TODO : Remove, if the Install Tool handles such data types correctly
450 * @return \TYPO3\CMS\Core\Core\Bootstrap
451 */
452 protected function convertPageNotFoundHandlingToBoolean() {
453 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
454 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
455 }
456 return $this;
457 }
458
459 /**
460 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
461 *
462 * Note: Yes, this is possible in php! xdebug() is then a global function, even
463 * if registerGlobalDebugFunctions() is encapsulated in class scope.
464 *
465 * @return \TYPO3\CMS\Core\Core\Bootstrap
466 */
467 protected function registerGlobalDebugFunctions() {
468 require_once('GlobalDebugFunctions.php');
469 return $this;
470 }
471
472 /**
473 * Mail sending via Swift Mailer
474 *
475 * @return \TYPO3\CMS\Core\Core\Bootstrap
476 */
477 protected function registerSwiftMailer() {
478 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] = 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
479 return $this;
480 }
481
482 /**
483 * Configure and set up exception and error handling
484 *
485 * @return \TYPO3\CMS\Core\Core\Bootstrap
486 */
487 protected function configureExceptionHandling() {
488 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
489 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
490 // Turn error logging on/off.
491 if (($displayErrors = intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'])) != '-1') {
492 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
493 if ($displayErrors == 2) {
494 if (\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
495 $displayErrors = 1;
496 } else {
497 $displayErrors = 0;
498 }
499 }
500 if ($displayErrors == 0) {
501 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
502 }
503 if ($displayErrors == 1) {
504 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
505 define('TYPO3_ERRORHANDLER_MODE', 'debug');
506 }
507 @ini_set('display_errors', $displayErrors);
508 } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
509 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
510 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
511 }
512 return $this;
513 }
514
515 /**
516 * Set PHP memory limit depending on value of
517 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
518 *
519 * @return \TYPO3\CMS\Core\Core\Bootstrap
520 */
521 protected function setMemoryLimit() {
522 if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) > 16) {
523 @ini_set('memory_limit', (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']) . 'm'));
524 }
525 return $this;
526 }
527
528 /**
529 * Define TYPO3_REQUESTTYPE* constants
530 * so devs exactly know what type of request it is
531 *
532 * @return \TYPO3\CMS\Core\Core\Bootstrap
533 */
534 protected function defineTypo3RequestTypes() {
535 define('TYPO3_REQUESTTYPE_FE', 1);
536 define('TYPO3_REQUESTTYPE_BE', 2);
537 define('TYPO3_REQUESTTYPE_CLI', 4);
538 define('TYPO3_REQUESTTYPE_AJAX', 8);
539 define('TYPO3_REQUESTTYPE_INSTALL', 16);
540 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));
541 return $this;
542 }
543
544 /**
545 * Set up $GLOBALS['TYPO3_LOADED_EXT'] array with basic information
546 * about extensions.
547 *
548 * @param boolean $allowCaching
549 * @return \TYPO3\CMS\Core\Core\Bootstrap
550 */
551 protected function populateTypo3LoadedExtGlobal($allowCaching = TRUE) {
552 $GLOBALS['TYPO3_LOADED_EXT'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadTypo3LoadedExtensionInformation($allowCaching);
553 return $this;
554 }
555
556 /**
557 * Load extension configuration files (ext_localconf.php)
558 *
559 * The ext_localconf.php files in extensions are meant to make changes
560 * to the global $TYPO3_CONF_VARS configuration array.
561 *
562 * @param boolean $allowCaching
563 * @return \TYPO3\CMS\Core\Core\Bootstrap
564 */
565 protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
566 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
567 return $this;
568 }
569
570 /**
571 * Write deprecation log if deprecated extCache setting was set in the instance.
572 *
573 * @return \TYPO3\CMS\Core\Core\Bootstrap
574 * @deprecated since 6.0, the check will be removed two version later.
575 */
576 protected function deprecationLogForOldExtCacheSetting() {
577 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] !== -1) {
578 \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog('Setting $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'extCache\'] is unused and can be removed from localconf.php');
579 }
580 return $this;
581 }
582
583 /**
584 * Initialize exception handling
585 *
586 * @return \TYPO3\CMS\Core\Core\Bootstrap
587 */
588 protected function initializeExceptionHandling() {
589 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] !== '') {
590 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] !== '') {
591 // Register an error handler for the given errorHandlerErrors
592 $errorHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
593 // Set errors which will be converted in an exception
594 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
595 }
596 // Instantiate the exception handler once to make sure object is registered
597 // @TODO: Figure out if this is really needed
598 \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
599 }
600 return $this;
601 }
602
603 /**
604 * Extensions may register new caches, so we set the
605 * global cache array to the manager again at this point
606 *
607 * @return \TYPO3\CMS\Core\Core\Bootstrap
608 */
609 protected function setFinalCachingFrameworkCacheConfiguration() {
610 $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
611 return $this;
612 }
613
614 /**
615 * Define logging and exception constants
616 *
617 * @return \TYPO3\CMS\Core\Core\Bootstrap
618 */
619 protected function defineLoggingAndExceptionConstants() {
620 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
621 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
622 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
623 return $this;
624 }
625
626 /**
627 * Unsetting reserved global variables:
628 * Those are set in "ext:core/ext_tables.php" file:
629 *
630 * @return \TYPO3\CMS\Core\Core\Bootstrap
631 */
632 protected function unsetReservedGlobalVariables() {
633 unset($GLOBALS['PAGES_TYPES']);
634 unset($GLOBALS['TCA']);
635 unset($GLOBALS['TBE_MODULES']);
636 unset($GLOBALS['TBE_STYLES']);
637 unset($GLOBALS['FILEICONS']);
638 // Those set in init.php:
639 unset($GLOBALS['WEBMOUNTS']);
640 unset($GLOBALS['FILEMOUNTS']);
641 unset($GLOBALS['BE_USER']);
642 // Those set otherwise:
643 unset($GLOBALS['TBE_MODULES_EXT']);
644 unset($GLOBALS['TCA_DESCR']);
645 unset($GLOBALS['LOCAL_LANG']);
646 unset($GLOBALS['TYPO3_AJAX']);
647 return $this;
648 }
649
650 /**
651 * Initialize t3lib_db in $GLOBALS and connect if requested
652 *
653 * @param boolean $connect Whether db should be connected
654 * @return \TYPO3\CMS\Core\Core\Bootstrap
655 * @internal This is not a public API method, do not use in own extensions
656 */
657 public function initializeTypo3DbGlobal($connect = TRUE) {
658 /** @var TYPO3_DB TYPO3\CMS\Core\Database\DatabaseConnection */
659 $GLOBALS['TYPO3_DB'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
660 $GLOBALS['TYPO3_DB']->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
661 if ($connect) {
662 $this->establishDatabaseConnection();
663 }
664 return $this;
665 }
666
667 /**
668 * Check adminOnly configuration variable and redirects
669 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
670 *
671 * @throws \RuntimeException
672 * @return \TYPO3\CMS\Core\Core\Bootstrap
673 * @internal This is not a public API method, do not use in own extensions
674 */
675 public function checkLockedBackendAndRedirectOrDie() {
676 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
677 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);
678 }
679 if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
680 if (TYPO3_PROCEED_IF_NO_USER === 2) {
681
682 } else {
683 $fileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
684 if ($fileContent) {
685 header('Location: ' . $fileContent);
686 } else {
687 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);
688 }
689 die;
690 }
691 }
692 return $this;
693 }
694
695 /**
696 * Compare client IP with IPmaskList and exit the script run
697 * if the client is not allowed to access the backend
698 *
699 * @return \TYPO3\CMS\Core\Core\Bootstrap
700 * @internal This is not a public API method, do not use in own extensions
701 */
702 public function checkBackendIpOrDie() {
703 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
704 if (!\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
705 // Send Not Found header - if the webserver can make use of it
706 header('Status: 404 Not Found');
707 // Just point us away from here...
708 header('Location: http://');
709 // ... and exit good!
710 die;
711 }
712 }
713 return $this;
714 }
715
716 /**
717 * Check lockSSL configuration variable and redirect
718 * to https version of the backend if needed
719 *
720 * @return \TYPO3\CMS\Core\Core\Bootstrap
721 * @internal This is not a public API method, do not use in own extensions
722 */
723 public function checkSslBackendAndRedirectIfNeeded() {
724 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'])) {
725 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'])) {
726 $sslPortSuffix = ':' . intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']);
727 } else {
728 $sslPortSuffix = '';
729 }
730 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
731 $requestStr = substr(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir));
732 if ($requestStr === 'index.php' && !\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
733 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 2);
734 list($server, $address) = explode('/', $url, 2);
735 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
736 die;
737 }
738 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
739 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) === 2) {
740 list(, $url) = explode('://', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
741 list($server, $address) = explode('/', $url, 2);
742 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
743 } else {
744 // Send Not Found header - if the webserver can make use of it...
745 header('Status: 404 Not Found');
746 // Just point us away from here...
747 header('Location: http://');
748 }
749 // ... and exit good!
750 die;
751 }
752 }
753 return $this;
754 }
755
756 /**
757 * Establish connection to the database
758 *
759 * @return \TYPO3\CMS\Core\Core\Bootstrap
760 * @internal This is not a public API method, do not use in own extensions
761 */
762 public function establishDatabaseConnection() {
763 $GLOBALS['TYPO3_DB']->connectDB();
764 return $this;
765 }
766
767 /**
768 * Load TCA for frontend
769 *
770 * This method is *only* executed in frontend scope. The idea is to execute the
771 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
772 * and then cache the full TCA on disk to be used for the next run again.
773 *
774 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
775 * is still always there.
776 *
777 * @return \TYPO3\CMS\Core\Core\Bootstrap
778 * @internal This is not a public API method, do not use in own extensions
779 */
780 public function loadCachedTca() {
781 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
782 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
783 $codeCache = $GLOBALS['typo3CacheManager']->getCache('cache_core');
784 if ($codeCache->has($cacheIdentifier)) {
785 $codeCache->requireOnce($cacheIdentifier);
786 } else {
787 $this->loadExtensionTables(TRUE);
788 $phpCodeToCache = '$GLOBALS[\'TCA\'] = ';
789 $phpCodeToCache .= \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($GLOBALS['TCA']);
790 $phpCodeToCache .= ';';
791 $codeCache->set($cacheIdentifier, $phpCodeToCache);
792 }
793 return $this;
794 }
795
796 /**
797 * Load ext_tables and friends.
798 *
799 * This will mainly set up $TCA and several other global arrays
800 * through API's like extMgm.
801 * Executes ext_tables.php files of loaded extensions or the
802 * according cache file if exists.
803 *
804 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
805 * @return \TYPO3\CMS\Core\Core\Bootstrap
806 * @internal This is not a public API method, do not use in own extensions
807 */
808 public function loadExtensionTables($allowCaching = TRUE) {
809 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
810 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
811 $this->executeExtTablesAdditionalFile();
812 $this->runExtTablesPostProcessingHooks();
813 return $this;
814 }
815
816 /**
817 * Execute TYPO3_extTableDef_script if defined and exists
818 *
819 * Note: For backwards compatibility some global variables are
820 * explicitly set as global to be used without $GLOBALS[] in
821 * the extension table script. It is discouraged to access variables like
822 * $TBE_MODULES directly, but we can not prohibit
823 * this without heavily breaking backwards compatibility.
824 *
825 * @TODO : We could write a scheduler / reports module or an update checker
826 * @TODO : It should be defined, which global arrays are ok to be manipulated
827 *
828 * @return void
829 */
830 protected function executeExtTablesAdditionalFile() {
831 // It is discouraged to use those global variables directly, but we
832 // can not prohibit this without breaking backwards compatibility
833 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
834 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
835 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
836 global $_EXTKEY;
837 // Load additional ext tables script if the file exists
838 $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
839 if (file_exists($extTablesFile)) {
840 include $extTablesFile;
841 }
842 }
843
844 /**
845 * Check for registered ext tables hooks and run them
846 *
847 * @throws \UnexpectedValueException
848 * @return void
849 */
850 protected function runExtTablesPostProcessingHooks() {
851 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
852 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
853 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
854 $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classReference);
855 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
856 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
857 }
858 $hookObject->processData();
859 }
860 }
861 }
862
863 /**
864 * Initialize sprite manager
865 *
866 * @return \TYPO3\CMS\Core\Core\Bootstrap
867 * @internal This is not a public API method, do not use in own extensions
868 */
869 public function initializeSpriteManager() {
870 \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
871 return $this;
872 }
873
874 /**
875 * Initialize backend user object in globals
876 *
877 * @return \TYPO3\CMS\Core\Core\Bootstrap
878 * @internal This is not a public API method, do not use in own extensions
879 */
880 public function initializeBackendUser() {
881 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
882 $backendUser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
883 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
884 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
885 $backendUser->auth_timeout_field = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout']);
886 $backendUser->OS = TYPO3_OS;
887 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
888 $backendUser->dontSetCookie = TRUE;
889 }
890 // The global must be available very early, because methods below
891 // might triger code which relies on it. See: #45625
892 $GLOBALS['BE_USER'] = $backendUser;
893 $backendUser->start();
894 $backendUser->checkCLIuser();
895 $backendUser->backendCheckLogin();
896 return $this;
897 }
898
899 /**
900 * Initialize backend user mount points
901 *
902 * @return \TYPO3\CMS\Core\Core\Bootstrap
903 * @internal This is not a public API method, do not use in own extensions
904 */
905 public function initializeBackendUserMounts() {
906 // Includes deleted mount pages as well! @TODO: Figure out why ...
907 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
908 $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
909 return $this;
910 }
911
912 /**
913 * Initialize language object
914 *
915 * @return \TYPO3\CMS\Core\Core\Bootstrap
916 * @internal This is not a public API method, do not use in own extensions
917 */
918 public function initializeLanguageObject() {
919 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
920 $GLOBALS['LANG'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Lang\LanguageService');
921 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
922 return $this;
923 }
924
925 /**
926 * Throw away all output that may have happened during bootstrapping by weird extensions
927 *
928 * @return \TYPO3\CMS\Core\Core\Bootstrap
929 * @internal This is not a public API method, do not use in own extensions
930 */
931 public function endOutputBufferingAndCleanPreviousOutput() {
932 ob_clean();
933 return $this;
934 }
935
936 /**
937 * Initialize output compression if configured
938 *
939 * @return \TYPO3\CMS\Core\Core\Bootstrap
940 * @internal This is not a public API method, do not use in own extensions
941 */
942 public function initializeOutputCompression() {
943 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
944 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
945 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
946 }
947 ob_start('ob_gzhandler');
948 }
949 return $this;
950 }
951
952 /**
953 * Initialize module menu object
954 *
955 * @return \TYPO3\CMS\Core\Core\Bootstrap
956 * @internal This is not a public API method, do not use in own extensions
957 */
958 public function initializeModuleMenuObject() {
959 /** @var $moduleMenuUtility Typo3_BackendModule_Utility */
960 $moduleMenuUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleController');
961 $moduleMenuUtility->createModuleMenu();
962 return $this;
963 }
964
965 /**
966 * Things that should be performed to shut down the framework.
967 * This method is called in all important scripts for a clean
968 * shut down of the system.
969 *
970 * @return \TYPO3\CMS\Core\Core\Bootstrap
971 * @internal This is not a public API method, do not use in own extensions
972 */
973 public function shutdown() {
974 if (PHP_VERSION_ID < 50307) {
975 \TYPO3\CMS\Core\Compatibility\CompatbilityClassLoaderPhpBelow50307::unregisterAutoloader();
976 } else {
977 \TYPO3\CMS\Core\Core\ClassLoader::unregisterAutoloader();
978 }
979 return $this;
980 }
981
982 /**
983 * Provides an instance of "template" for backend-modules to
984 * work with.
985 *
986 * @return \TYPO3\CMS\Core\Core\Bootstrap
987 * @internal This is not a public API method, do not use in own extensions
988 */
989 public function initializeBackendTemplate() {
990 $GLOBALS['TBE_TEMPLATE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
991 return $this;
992 }
993
994 }
995
996
997 ?>