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