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