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