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