1c43dbaaddabe66e32598430a08e55e9bde9c2a6
[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: Move this functionality to the silent updater in the Install Tool
468 * @return Bootstrap
469 */
470 protected function transferDeprecatedCurlSettings() {
471 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) && empty($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'])) {
472 $curlProxy = rtrim(preg_replace('#^https?://#', '', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']), '/');
473 $proxyParts = Utility\GeneralUtility::revExplode(':', $curlProxy, 2);
474 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_host'] = $proxyParts[0];
475 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_port'] = $proxyParts[1];
476 }
477 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']) && empty($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'])) {
478 $userPassParts = explode(':', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'], 2);
479 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_user'] = $userPassParts[0];
480 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy_password'] = $userPassParts[1];
481 }
482 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse']) {
483 $GLOBALS['TYPO3_CONF_VARS']['HTTP']['adapter'] = 'curl';
484 }
485 return $this;
486 }
487
488 /**
489 * Set cacheHash options
490 *
491 * @return Bootstrap
492 */
493 protected function setCacheHashOptions() {
494 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
495 'cachedParametersWhiteList' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], TRUE),
496 'excludedParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], TRUE),
497 'requireCacheHashPresenceParameters' => Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], TRUE)
498 );
499 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
500 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = TRUE;
501 } else {
502 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], TRUE);
503 }
504 return $this;
505 }
506
507 /**
508 * Set default timezone
509 *
510 * @return Bootstrap
511 */
512 protected function setDefaultTimezone() {
513 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
514 if (empty($timeZone)) {
515 // Time zone from the server environment (TZ env or OS query)
516 $defaultTimeZone = @date_default_timezone_get();
517 if ($defaultTimeZone !== '') {
518 $timeZone = $defaultTimeZone;
519 } else {
520 $timeZone = 'UTC';
521 }
522 }
523 // Set default to avoid E_WARNINGs with PHP > 5.3
524 date_default_timezone_set($timeZone);
525 return $this;
526 }
527
528 /**
529 * Initialize the locales handled by TYPO3
530 *
531 * @return Bootstrap
532 */
533 protected function initializeL10nLocales() {
534 \TYPO3\CMS\Core\Localization\Locales::initialize();
535 return $this;
536 }
537
538 /**
539 * Convert type of "pageNotFound_handling" setting in case it was written as a
540 * string (e.g. if edited in Install Tool)
541 *
542 * @TODO : Remove, if the Install Tool handles such data types correctly
543 * @return Bootstrap
544 */
545 protected function convertPageNotFoundHandlingToBoolean() {
546 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
547 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = TRUE;
548 }
549 return $this;
550 }
551
552 /**
553 * Register xdebug(), debug(), debugBegin() and debugEnd() as global functions
554 *
555 * Note: Yes, this is possible in php! xdebug() is then a global function, even
556 * if registerGlobalDebugFunctions() is encapsulated in class scope.
557 *
558 * @return Bootstrap
559 */
560 protected function registerGlobalDebugFunctions() {
561 require_once('GlobalDebugFunctions.php');
562 return $this;
563 }
564
565 /**
566 * Mail sending via Swift Mailer
567 *
568 * @return \TYPO3\CMS\Core\Core\Bootstrap
569 * @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
570 */
571 protected function registerSwiftMailer() {
572 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] =
573 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
574 return $this;
575 }
576
577 /**
578 * Configure and set up exception and error handling
579 *
580 * @return Bootstrap
581 */
582 protected function configureExceptionHandling() {
583 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
584 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
585 $doesIpMatch = Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
586 $displayErrors = (int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'];
587 // Turn error logging on/off.
588 if ($displayErrors !== -1) {
589 // Special value "2" enables this feature only if $GLOBALS['TYPO3_CONF_VARS'][SYS][devIPmask] matches
590 if ($displayErrors === 2) {
591 $displayErrors = (int)$doesIpMatch;
592 }
593 if ($displayErrors === 0) {
594 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors'] = 0;
595 }
596 if ($displayErrors === 1) {
597 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
598 define('TYPO3_ERRORHANDLER_MODE', 'debug');
599 }
600 @ini_set('display_errors', $displayErrors);
601 } elseif ($doesIpMatch) {
602 // With displayErrors = -1 (default), turn on debugging if devIPmask matches:
603 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
604 }
605 return $this;
606 }
607
608 /**
609 * Set PHP memory limit depending on value of
610 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
611 *
612 * @return Bootstrap
613 */
614 protected function setMemoryLimit() {
615 if ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] > 16) {
616 @ini_set('memory_limit', ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] . 'm'));
617 }
618 return $this;
619 }
620
621 /**
622 * Define TYPO3_REQUESTTYPE* constants
623 * so devs exactly know what type of request it is
624 *
625 * @return Bootstrap
626 */
627 protected function defineTypo3RequestTypes() {
628 define('TYPO3_REQUESTTYPE_FE', 1);
629 define('TYPO3_REQUESTTYPE_BE', 2);
630 define('TYPO3_REQUESTTYPE_CLI', 4);
631 define('TYPO3_REQUESTTYPE_AJAX', 8);
632 define('TYPO3_REQUESTTYPE_INSTALL', 16);
633 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));
634 return $this;
635 }
636
637 /**
638 * Load extension configuration files (ext_localconf.php)
639 *
640 * The ext_localconf.php files in extensions are meant to make changes
641 * to the global $TYPO3_CONF_VARS configuration array.
642 *
643 * @param boolean $allowCaching
644 * @return Bootstrap
645 */
646 protected function loadAdditionalConfigurationFromExtensions($allowCaching = TRUE) {
647 Utility\ExtensionManagementUtility::loadExtLocalconf($allowCaching);
648 return $this;
649 }
650
651 /**
652 * Initialize exception handling
653 *
654 * @return Bootstrap
655 */
656 protected function initializeExceptionHandling() {
657 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler'])) {
658 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'])) {
659 // Register an error handler for the given errorHandlerErrors
660 $errorHandler = Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors']);
661 // Set errors which will be converted in an exception
662 $errorHandler->setExceptionalErrors($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionalErrors']);
663 }
664 // Instantiate the exception handler once to make sure object is registered
665 // @TODO: Figure out if this is really needed
666 Utility\GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['errors']['exceptionHandler']);
667 }
668 return $this;
669 }
670
671 /**
672 * Extensions may register new caches, so we set the
673 * global cache array to the manager again at this point
674 *
675 * @return Bootstrap
676 */
677 protected function setFinalCachingFrameworkCacheConfiguration() {
678 $this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
679 return $this;
680 }
681
682 /**
683 * Define logging and exception constants
684 *
685 * @return Bootstrap
686 */
687 protected function defineLoggingAndExceptionConstants() {
688 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
689 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
690 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
691 return $this;
692 }
693
694 /**
695 * Unsetting reserved global variables:
696 * Those are set in "ext:core/ext_tables.php" file:
697 *
698 * @return Bootstrap
699 */
700 protected function unsetReservedGlobalVariables() {
701 unset($GLOBALS['PAGES_TYPES']);
702 unset($GLOBALS['TCA']);
703 unset($GLOBALS['TBE_MODULES']);
704 unset($GLOBALS['TBE_STYLES']);
705 unset($GLOBALS['FILEICONS']);
706 // Those set in init.php:
707 unset($GLOBALS['WEBMOUNTS']);
708 unset($GLOBALS['BE_USER']);
709 // Those set otherwise:
710 unset($GLOBALS['TBE_MODULES_EXT']);
711 unset($GLOBALS['TCA_DESCR']);
712 unset($GLOBALS['LOCAL_LANG']);
713 unset($GLOBALS['TYPO3_AJAX']);
714 return $this;
715 }
716
717 /**
718 * Initialize database connection in $GLOBALS and connect if requested
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 initializeTypo3DbGlobal() {
724 /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
725 $databaseConnection = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
726 $databaseConnection->setDatabaseName(TYPO3_db);
727 $databaseConnection->setDatabaseUsername(TYPO3_db_username);
728 $databaseConnection->setDatabasePassword(TYPO3_db_password);
729
730 $databaseHost = TYPO3_db_host;
731 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])) {
732 $databaseConnection->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['port']);
733 } elseif (strpos($databaseHost, ':') > 0) {
734 // @TODO: Find a way to handle this case in the install tool and drop this
735 list($databaseHost, $databasePort) = explode(':', $databaseHost);
736 $databaseConnection->setDatabasePort($databasePort);
737 }
738 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])) {
739 $databaseConnection->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
740 }
741 $databaseConnection->setDatabaseHost($databaseHost);
742
743 $databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
744
745 if (
746 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'])
747 && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']
748 ) {
749 $databaseConnection->setPersistentDatabaseConnection(TRUE);
750 }
751
752 $isDatabaseHostLocalHost = $databaseHost === 'localhost' || $databaseHost === '127.0.0.1' || $databaseHost === '::1';
753 if (
754 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress'])
755 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress']
756 && !$isDatabaseHostLocalHost
757 ) {
758 $databaseConnection->setConnectionCompression(TRUE);
759 }
760
761 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'])) {
762 $commandsAfterConnect = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
763 LF,
764 str_replace('\' . LF . \'', LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']),
765 TRUE
766 );
767 $databaseConnection->setInitializeCommandsAfterConnect($commandsAfterConnect);
768 }
769
770 $GLOBALS['TYPO3_DB'] = $databaseConnection;
771 // $GLOBALS['TYPO3_DB'] needs to be defined first in order to work for DBAL
772 $GLOBALS['TYPO3_DB']->initialize();
773
774 return $this;
775 }
776
777 /**
778 * Check adminOnly configuration variable and redirects
779 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
780 *
781 * @throws \RuntimeException
782 * @return Bootstrap
783 * @internal This is not a public API method, do not use in own extensions
784 */
785 public function checkLockedBackendAndRedirectOrDie() {
786 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
787 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);
788 }
789 if (@is_file((PATH_typo3conf . 'LOCK_BACKEND'))) {
790 if (TYPO3_PROCEED_IF_NO_USER === 2) {
791
792 } else {
793 $fileContent = Utility\GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
794 if ($fileContent) {
795 header('Location: ' . $fileContent);
796 } else {
797 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);
798 }
799 die;
800 }
801 }
802 return $this;
803 }
804
805 /**
806 * Compare client IP with IPmaskList and exit the script run
807 * if the client is not allowed to access the backend
808 *
809 * @return Bootstrap
810 * @internal This is not a public API method, do not use in own extensions
811 * @throws \RuntimeException
812 */
813 public function checkBackendIpOrDie() {
814 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
815 if (!Utility\GeneralUtility::cmpIP(Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
816 throw new \RuntimeException('TYPO3 Backend access denied: The IP address of your client does not match the list of allowed IP addresses.', 1389265900);
817 }
818 }
819 return $this;
820 }
821
822 /**
823 * Check lockSSL configuration variable and redirect
824 * to https version of the backend if needed
825 *
826 * @return Bootstrap
827 * @internal This is not a public API method, do not use in own extensions
828 * @throws \RuntimeException
829 */
830 public function checkSslBackendAndRedirectIfNeeded() {
831 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) {
832 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']) {
833 $sslPortSuffix = ':' . (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'];
834 } else {
835 $sslPortSuffix = '';
836 }
837 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] == 3) {
838 $requestStr = substr(Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT'), strlen(Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir));
839 if ($requestStr === 'index.php' && !Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
840 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), 2);
841 list($server, $address) = explode('/', $url, 2);
842 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
843 die;
844 }
845 } elseif (!Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
846 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] === 2) {
847 list(, $url) = explode('://', Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
848 list($server, $address) = explode('/', $url, 2);
849 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
850 die;
851 } else {
852 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);
853 }
854 }
855 }
856 return $this;
857 }
858
859 /**
860 * Load TCA for frontend
861 *
862 * This method is *only* executed in frontend scope. The idea is to execute the
863 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
864 * and then cache the full TCA on disk to be used for the next run again.
865 *
866 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
867 * is still always there.
868 *
869 * @return Bootstrap
870 * @internal This is not a public API method, do not use in own extensions
871 */
872 public function loadCachedTca() {
873 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
874 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
875 $codeCache = $this->getEarlyInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_core');
876 if ($codeCache->has($cacheIdentifier)) {
877 // substr is necessary, because the php frontend wraps php code around the cache value
878 $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
879 } else {
880 $this->loadExtensionTables(TRUE);
881 $codeCache->set($cacheIdentifier, serialize($GLOBALS['TCA']));
882 }
883 return $this;
884 }
885
886 /**
887 * Load ext_tables and friends.
888 *
889 * This will mainly set up $TCA and several other global arrays
890 * through API's like extMgm.
891 * Executes ext_tables.php files of loaded extensions or the
892 * according cache file if exists.
893 *
894 * @param boolean $allowCaching True, if reading compiled ext_tables file from cache is allowed
895 * @return Bootstrap
896 * @internal This is not a public API method, do not use in own extensions
897 */
898 public function loadExtensionTables($allowCaching = TRUE) {
899 Utility\ExtensionManagementUtility::loadBaseTca($allowCaching);
900 Utility\ExtensionManagementUtility::loadExtTables($allowCaching);
901 $this->executeExtTablesAdditionalFile();
902 $this->runExtTablesPostProcessingHooks();
903 return $this;
904 }
905
906 /**
907 * Execute TYPO3_extTableDef_script if defined and exists
908 *
909 * Note: For backwards compatibility some global variables are
910 * explicitly set as global to be used without $GLOBALS[] in
911 * the extension table script. It is discouraged to access variables like
912 * $TBE_MODULES directly, but we can not prohibit
913 * this without heavily breaking backwards compatibility.
914 *
915 * @TODO : We could write a scheduler / reports module or an update checker
916 * @TODO : It should be defined, which global arrays are ok to be manipulated
917 *
918 * @return void
919 */
920 protected function executeExtTablesAdditionalFile() {
921 // It is discouraged to use those global variables directly, but we
922 // can not prohibit this without breaking backwards compatibility
923 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
924 global $TBE_MODULES, $TBE_MODULES_EXT, $TCA;
925 global $PAGES_TYPES, $TBE_STYLES, $FILEICONS;
926 global $_EXTKEY;
927 // Load additional ext tables script if the file exists
928 $extTablesFile = PATH_typo3conf . TYPO3_extTableDef_script;
929 if (file_exists($extTablesFile) && is_file($extTablesFile)) {
930 include $extTablesFile;
931 }
932 }
933
934 /**
935 * Check for registered ext tables hooks and run them
936 *
937 * @throws \UnexpectedValueException
938 * @return void
939 */
940 protected function runExtTablesPostProcessingHooks() {
941 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
942 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
943 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
944 $hookObject = Utility\GeneralUtility::getUserObj($classReference);
945 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
946 throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface', 1320585902);
947 }
948 $hookObject->processData();
949 }
950 }
951 }
952
953 /**
954 * Initialize sprite manager
955 *
956 * @return Bootstrap
957 * @internal This is not a public API method, do not use in own extensions
958 */
959 public function initializeSpriteManager() {
960 \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize();
961 return $this;
962 }
963
964 /**
965 * Initialize backend user object in globals
966 *
967 * @return Bootstrap
968 * @internal This is not a public API method, do not use in own extensions
969 */
970 public function initializeBackendUser() {
971 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
972 $backendUser = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
973 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
974 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
975 $backendUser->auth_timeout_field = (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'];
976 $backendUser->OS = TYPO3_OS;
977 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
978 $backendUser->dontSetCookie = TRUE;
979 }
980 // The global must be available very early, because methods below
981 // might trigger code which relies on it. See: #45625
982 $GLOBALS['BE_USER'] = $backendUser;
983 $backendUser->start();
984 return $this;
985 }
986
987 /**
988 * Initializes and ensures authenticated access
989 *
990 * @internal This is not a public API method, do not use in own extensions
991 * @return \TYPO3\CMS\Core\Core\Bootstrap
992 */
993 public function initializeBackendAuthentication() {
994 $GLOBALS['BE_USER']->checkCLIuser();
995 $GLOBALS['BE_USER']->backendCheckLogin();
996 return $this;
997 }
998
999 /**
1000 * Initialize backend user mount points
1001 *
1002 * @return Bootstrap
1003 * @internal This is not a public API method, do not use in own extensions
1004 */
1005 public function initializeBackendUserMounts() {
1006 // Includes deleted mount pages as well! @TODO: Figure out why ...
1007 $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
1008 return $this;
1009 }
1010
1011 /**
1012 * Initialize language object
1013 *
1014 * @return Bootstrap
1015 * @internal This is not a public API method, do not use in own extensions
1016 */
1017 public function initializeLanguageObject() {
1018 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
1019 $GLOBALS['LANG'] = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
1020 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
1021 return $this;
1022 }
1023
1024 /**
1025 * Throw away all output that may have happened during bootstrapping by weird extensions
1026 *
1027 * @return Bootstrap
1028 * @internal This is not a public API method, do not use in own extensions
1029 */
1030 public function endOutputBufferingAndCleanPreviousOutput() {
1031 ob_clean();
1032 return $this;
1033 }
1034
1035 /**
1036 * Initialize output compression if configured
1037 *
1038 * @return Bootstrap
1039 * @internal This is not a public API method, do not use in own extensions
1040 */
1041 public function initializeOutputCompression() {
1042 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
1043 if (Utility\MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
1044 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
1045 }
1046 ob_start('ob_gzhandler');
1047 }
1048 return $this;
1049 }
1050
1051 /**
1052 * Send HTTP headers if configured
1053 *
1054 * @return Bootstrap
1055 * @internal This is not a public API method, do not use in own extensions
1056 */
1057 public function sendHttpHeaders() {
1058 if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers']) && is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'])) {
1059 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'] as $header) {
1060 header($header);
1061 }
1062 }
1063 return $this;
1064 }
1065
1066 /**
1067 * Things that should be performed to shut down the framework.
1068 * This method is called in all important scripts for a clean
1069 * shut down of the system.
1070 *
1071 * @return Bootstrap
1072 * @internal This is not a public API method, do not use in own extensions
1073 */
1074 public function shutdown() {
1075 return $this;
1076 }
1077
1078 /**
1079 * Provides an instance of "template" for backend-modules to
1080 * work with.
1081 *
1082 * @return Bootstrap
1083 * @internal This is not a public API method, do not use in own extensions
1084 */
1085 public function initializeBackendTemplate() {
1086 $GLOBALS['TBE_TEMPLATE'] = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
1087 return $this;
1088 }
1089 }