[TASK] Removed deprecated code from lowlevel and utility functions
[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\ExtensionManagementUtility;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Core\Utility\MathUtility;
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 class Bootstrap
33 {
34 /**
35 * @var \TYPO3\CMS\Core\Core\Bootstrap
36 */
37 protected static $instance = null;
38
39 /**
40 * Unique Request ID
41 *
42 * @var string
43 */
44 protected $requestId;
45
46 /**
47 * The application context
48 *
49 * @var \TYPO3\CMS\Core\Core\ApplicationContext
50 */
51 protected $applicationContext;
52
53 /**
54 * @var array List of early instances
55 */
56 protected $earlyInstances = array();
57
58 /**
59 * @var string Path to install tool
60 */
61 protected $installToolPath;
62
63 /**
64 * A list of all registered request handlers, see the Application class / entry points for the registration
65 * @var \TYPO3\CMS\Core\Http\RequestHandlerInterface[]|\TYPO3\CMS\Core\Console\RequestHandlerInterface[]
66 */
67 protected $availableRequestHandlers = array();
68
69 /**
70 * The Response object when using Request/Response logic
71 * @var \Psr\Http\Message\ResponseInterface
72 * @see shutdown()
73 */
74 protected $response;
75
76 /**
77 * @var bool
78 */
79 protected static $usesComposerClassLoading = false;
80
81 /**
82 * Disable direct creation of this object.
83 * Set unique requestId and the application context
84 *
85 * @var string Application context
86 */
87 protected function __construct($applicationContext)
88 {
89 $this->requestId = substr(md5(uniqid('', true)), 0, 13);
90 $this->applicationContext = new ApplicationContext($applicationContext);
91 }
92
93 /**
94 * @return bool
95 */
96 public static function usesComposerClassLoading()
97 {
98 return self::$usesComposerClassLoading;
99 }
100
101 /**
102 * Disable direct cloning of this object.
103 */
104 protected function __clone()
105 {
106 }
107
108 /**
109 * Return 'this' as singleton
110 *
111 * @return Bootstrap
112 * @internal This is not a public API method, do not use in own extensions
113 */
114 public static function getInstance()
115 {
116 if (is_null(static::$instance)) {
117 $applicationContext = getenv('TYPO3_CONTEXT') ?: (getenv('REDIRECT_TYPO3_CONTEXT') ?: 'Production');
118 self::$instance = new static($applicationContext);
119 }
120 return static::$instance;
121 }
122
123 /**
124 * Gets the request's unique ID
125 *
126 * @return string Unique request ID
127 * @internal This is not a public API method, do not use in own extensions
128 */
129 public function getRequestId()
130 {
131 return $this->requestId;
132 }
133
134 /**
135 * Returns the application context this bootstrap was started in.
136 *
137 * @return \TYPO3\CMS\Core\Core\ApplicationContext The application context encapsulated in an object
138 * @internal This is not a public API method, do not use in own extensions.
139 * Use \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext() instead
140 */
141 public function getApplicationContext()
142 {
143 return $this->applicationContext;
144 }
145
146 /**
147 * Prevent any unwanted output that may corrupt AJAX/compression.
148 * This does not interfere with "die()" or "echo"+"exit()" messages!
149 *
150 * @return Bootstrap
151 * @internal This is not a public API method, do not use in own extensions
152 */
153 public function startOutputBuffering()
154 {
155 ob_start();
156 return $this;
157 }
158
159 /**
160 * Main entry point called at every request usually from Global scope. Checks if everything is correct,
161 * and loads the Configuration.
162 *
163 * Make sure that the baseSetup() is called before and the class loader is present
164 *
165 * @return Bootstrap
166 */
167 public function configure()
168 {
169 $this->startOutputBuffering()
170 ->loadConfigurationAndInitialize()
171 ->loadTypo3LoadedExtAndExtLocalconf(true)
172 ->setFinalCachingFrameworkCacheConfiguration()
173 ->defineLoggingAndExceptionConstants()
174 ->unsetReservedGlobalVariables()
175 ->initializeTypo3DbGlobal();
176
177 return $this;
178 }
179
180 /**
181 * Run the base setup that checks server environment, determines pathes,
182 * populates base files and sets common configuration.
183 *
184 * Script execution will be aborted if something fails here.
185 *
186 * @param string $relativePathPart Relative path of entry script back to document root
187 * @return Bootstrap
188 * @internal This is not a public API method, do not use in own extensions
189 */
190 public function baseSetup($relativePathPart = '')
191 {
192 SystemEnvironmentBuilder::run($relativePathPart);
193 if (!self::$usesComposerClassLoading && ClassLoadingInformation::isClassLoadingInformationAvailable()) {
194 ClassLoadingInformation::registerClassLoadingInformation();
195 }
196 GeneralUtility::presetApplicationContext($this->applicationContext);
197 return $this;
198 }
199
200 /**
201 * Sets the class loader to the bootstrap
202 *
203 * @param \Composer\Autoload\ClassLoader $classLoader an instance of the class loader
204 * @return Bootstrap
205 * @internal This is not a public API method, do not use in own extensions
206 */
207 public function initializeClassLoader($classLoader)
208 {
209 $this->setEarlyInstance(\Composer\Autoload\ClassLoader::class, $classLoader);
210 if (defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE) {
211 self::$usesComposerClassLoading = true;
212 }
213 return $this;
214 }
215
216 /**
217 * checks if LocalConfiguration.php or PackageStates.php is missing,
218 * used to see if a redirect to the install tool is needed
219 *
220 * @return bool TRUE when the essential configuration is available, otherwise FALSE
221 * @internal This is not a public API method, do not use in own extensions
222 */
223 public function checkIfEssentialConfigurationExists()
224 {
225 $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager;
226 $this->setEarlyInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class, $configurationManager);
227 return file_exists($configurationManager->getLocalConfigurationFileLocation()) && file_exists(PATH_typo3conf . 'PackageStates.php');
228 }
229
230 /**
231 * Redirect to install tool if LocalConfiguration.php is missing.
232 *
233 * @internal This is not a public API method, do not use in own extensions
234 */
235 public function redirectToInstallTool($relativePathPart = '')
236 {
237 $backPathToSiteRoot = str_repeat('../', count(explode('/', $relativePathPart)) - 1);
238 header('Location: ' . $backPathToSiteRoot . 'typo3/sysext/install/Start/Install.php');
239 die;
240 }
241
242 /**
243 * Adds available request handlers usually done via an application from the outside.
244 *
245 * @param string $requestHandler class which implements the request handler interface
246 * @return Bootstrap
247 * @internal This is not a public API method, do not use in own extensions
248 */
249 public function registerRequestHandlerImplementation($requestHandler)
250 {
251 $this->availableRequestHandlers[] = $requestHandler;
252 return $this;
253 }
254
255 /**
256 * Fetches the request handler that suits the best based on the priority and the interface
257 * Be sure to always have the constants that are defined in $this->defineTypo3RequestTypes() are set,
258 * so most RequestHandlers can check if they can handle the request.
259 *
260 * @param \Psr\Http\Message\ServerRequestInterface|\Symfony\Component\Console\Input\InputInterface $request
261 * @return \TYPO3\CMS\Core\Http\RequestHandlerInterface|\TYPO3\CMS\Core\Console\RequestHandlerInterface
262 * @throws \TYPO3\CMS\Core\Exception
263 * @internal This is not a public API method, do not use in own extensions
264 */
265 protected function resolveRequestHandler($request)
266 {
267 $suitableRequestHandlers = array();
268 foreach ($this->availableRequestHandlers as $requestHandlerClassName) {
269 /** @var \TYPO3\CMS\Core\Http\RequestHandlerInterface|\TYPO3\CMS\Core\Console\RequestHandlerInterface $requestHandler */
270 $requestHandler = GeneralUtility::makeInstance($requestHandlerClassName, $this);
271 if ($requestHandler->canHandleRequest($request)) {
272 $priority = $requestHandler->getPriority();
273 if (isset($suitableRequestHandlers[$priority])) {
274 throw new \TYPO3\CMS\Core\Exception('More than one request handler with the same priority can handle the request, but only one handler may be active at a time!', 1176471352);
275 }
276 $suitableRequestHandlers[$priority] = $requestHandler;
277 }
278 }
279 if (empty($suitableRequestHandlers)) {
280 throw new \TYPO3\CMS\Core\Exception('No suitable request handler found.', 1225418233);
281 }
282 ksort($suitableRequestHandlers);
283 return array_pop($suitableRequestHandlers);
284 }
285
286 /**
287 * Builds a Request instance from the current process, and then resolves the request
288 * through the request handlers depending on Frontend, Backend, CLI etc.
289 *
290 * @param \Psr\Http\Message\RequestInterface|\Symfony\Component\Console\Input\InputInterface $request
291 * @return Bootstrap
292 * @throws \TYPO3\CMS\Core\Exception
293 * @internal This is not a public API method, do not use in own extensions
294 */
295 public function handleRequest($request)
296 {
297
298 // Resolve request handler that were registered based on the Application
299 $requestHandler = $this->resolveRequestHandler($request);
300
301 // Execute the command which returns a Response object or NULL
302 $this->response = $requestHandler->handleRequest($request);
303 return $this;
304 }
305
306 /**
307 * Outputs content if there is a proper Response object.
308 *
309 * @return Bootstrap
310 */
311 protected function sendResponse()
312 {
313 if ($this->response instanceof \Psr\Http\Message\ResponseInterface) {
314 if (!headers_sent()) {
315 foreach ($this->response->getHeaders() as $name => $values) {
316 header($name . ': ' . implode(', ', $values));
317 }
318 // If the response code was not changed by legacy code (still is 200)
319 // then allow the PSR-7 response object to explicitly set it.
320 // Otherwise let legacy code take precedence.
321 // This code path can be deprecated once we expose the response object to third party code
322 if (http_response_code() === 200) {
323 header('HTTP/' . $this->response->getProtocolVersion() . ' ' . $this->response->getStatusCode() . ' ' . $this->response->getReasonPhrase());
324 }
325 }
326 echo $this->response->getBody()->__toString();
327 }
328 return $this;
329 }
330
331 /**
332 * Registers the instance of the specified object for an early boot stage.
333 * On finalizing the Object Manager initialization, all those instances will
334 * be transferred to the Object Manager's registry.
335 *
336 * @param string $objectName Object name, as later used by the Object Manager
337 * @param object $instance The instance to register
338 * @return void
339 * @internal This is not a public API method, do not use in own extensions
340 */
341 public function setEarlyInstance($objectName, $instance)
342 {
343 $this->earlyInstances[$objectName] = $instance;
344 }
345
346 /**
347 * Returns an instance which was registered earlier through setEarlyInstance()
348 *
349 * @param string $objectName Object name of the registered instance
350 * @return object
351 * @throws \TYPO3\CMS\Core\Exception
352 * @internal This is not a public API method, do not use in own extensions
353 */
354 public function getEarlyInstance($objectName)
355 {
356 if (!isset($this->earlyInstances[$objectName])) {
357 throw new \TYPO3\CMS\Core\Exception('Unknown early instance "' . $objectName . '"', 1365167380);
358 }
359 return $this->earlyInstances[$objectName];
360 }
361
362 /**
363 * Returns all registered early instances indexed by object name
364 *
365 * @return array
366 * @internal This is not a public API method, do not use in own extensions
367 */
368 public function getEarlyInstances()
369 {
370 return $this->earlyInstances;
371 }
372
373 /**
374 * Includes LocalConfiguration.php and sets several
375 * global settings depending on configuration.
376 *
377 * @param bool $allowCaching Whether to allow caching - affects cache_core (autoloader)
378 * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer)
379 * @return Bootstrap
380 * @internal This is not a public API method, do not use in own extensions
381 */
382 public function loadConfigurationAndInitialize($allowCaching = true, $packageManagerClassName = \TYPO3\CMS\Core\Package\PackageManager::class)
383 {
384 $this->populateLocalConfiguration()
385 ->initializeErrorHandling();
386 if (!$allowCaching) {
387 $this->disableCoreCache();
388 }
389 $this->initializeCachingFramework()
390 ->initializePackageManagement($packageManagerClassName)
391 ->initializeRuntimeActivatedPackagesFromConfiguration()
392 ->defineDatabaseConstants()
393 ->defineUserAgentConstant()
394 ->registerExtDirectComponents()
395 ->setCacheHashOptions()
396 ->setDefaultTimezone()
397 ->initializeL10nLocales()
398 ->convertPageNotFoundHandlingToBoolean()
399 ->setMemoryLimit()
400 ->defineTypo3RequestTypes();
401 if ($allowCaching) {
402 $this->ensureClassLoadingInformationExists();
403 }
404 return $this;
405 }
406
407 /**
408 * Initializes the package system and loads the package configuration and settings
409 * provided by the packages.
410 *
411 * @param string $packageManagerClassName Define an alternative package manager implementation (usually for the installer)
412 * @return Bootstrap
413 * @internal This is not a public API method, do not use in own extensions
414 */
415 public function initializePackageManagement($packageManagerClassName)
416 {
417 /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */
418 $packageManager = new $packageManagerClassName();
419 $this->setEarlyInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
420 ExtensionManagementUtility::setPackageManager($packageManager);
421 $packageManager->injectCoreCache($this->getEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_core'));
422 $dependencyResolver = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Package\DependencyResolver::class);
423 $dependencyResolver->injectDependencyOrderingService(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Service\DependencyOrderingService::class));
424 $packageManager->injectDependencyResolver($dependencyResolver);
425 $packageManager->initialize($this);
426 GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
427 return $this;
428 }
429
430 /**
431 * Writes class loading information if not yet present
432 *
433 * @return Bootstrap
434 * @internal This is not a public API method, do not use in own extensions
435 */
436 public function ensureClassLoadingInformationExists()
437 {
438 if (!self::$usesComposerClassLoading && !ClassLoadingInformation::isClassLoadingInformationAvailable()) {
439 ClassLoadingInformation::dumpClassLoadingInformation();
440 ClassLoadingInformation::registerClassLoadingInformation();
441 }
442 return $this;
443 }
444
445 /**
446 * Activates a package during runtime. This is used in AdditionalConfiguration.php
447 * to enable extensions under conditions.
448 *
449 * @return Bootstrap
450 */
451 protected function initializeRuntimeActivatedPackagesFromConfiguration()
452 {
453 if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'])) {
454 /** @var \TYPO3\CMS\Core\Package\PackageManager $packageManager */
455 $packageManager = $this->getEarlyInstance(\TYPO3\CMS\Core\Package\PackageManager::class);
456 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'] as $runtimeAddedPackageKey) {
457 $packageManager->activatePackageDuringRuntime($runtimeAddedPackageKey);
458 }
459 }
460 return $this;
461 }
462
463 /**
464 * Load ext_localconf of extensions
465 *
466 * @param bool $allowCaching
467 * @return Bootstrap
468 * @internal This is not a public API method, do not use in own extensions
469 */
470 public function loadTypo3LoadedExtAndExtLocalconf($allowCaching = true)
471 {
472 ExtensionManagementUtility::loadExtLocalconf($allowCaching);
473 return $this;
474 }
475
476 /**
477 * We need an early instance of the configuration manager.
478 * Since makeInstance relies on the object configuration, we create it here with new instead.
479 *
480 * @return Bootstrap
481 * @internal This is not a public API method, do not use in own extensions
482 */
483 public function populateLocalConfiguration()
484 {
485 try {
486 $configurationManager = $this->getEarlyInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
487 } catch (\TYPO3\CMS\Core\Exception $exception) {
488 $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
489 $this->setEarlyInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class, $configurationManager);
490 }
491 $configurationManager->exportConfiguration();
492 return $this;
493 }
494
495 /**
496 * Set cache_core to null backend, effectively disabling eg. the cache for ext_localconf and PackageManager etc.
497 *
498 * @return \TYPO3\CMS\Core\Core\Bootstrap
499 * @internal This is not a public API method, do not use in own extensions
500 */
501 public function disableCoreCache()
502 {
503 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['backend']
504 = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class;
505 unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['options']);
506 return $this;
507 }
508
509 /**
510 * Define database constants
511 *
512 * @return \TYPO3\CMS\Core\Core\Bootstrap
513 */
514 protected function defineDatabaseConstants()
515 {
516 define('TYPO3_db', $GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
517 define('TYPO3_db_username', $GLOBALS['TYPO3_CONF_VARS']['DB']['username']);
518 define('TYPO3_db_password', $GLOBALS['TYPO3_CONF_VARS']['DB']['password']);
519 define('TYPO3_db_host', $GLOBALS['TYPO3_CONF_VARS']['DB']['host']);
520 return $this;
521 }
522
523 /**
524 * Define user agent constant
525 *
526 * @return \TYPO3\CMS\Core\Core\Bootstrap
527 */
528 protected function defineUserAgentConstant()
529 {
530 define('TYPO3_user_agent', 'User-Agent: ' . $GLOBALS['TYPO3_CONF_VARS']['HTTP']['userAgent']);
531 return $this;
532 }
533
534 /**
535 * Register default ExtDirect components
536 *
537 * @return Bootstrap
538 */
539 protected function registerExtDirectComponents()
540 {
541 if (TYPO3_MODE === 'BE') {
542 ExtensionManagementUtility::registerExtDirectComponent(
543 'TYPO3.Components.PageTree.DataProvider',
544 \TYPO3\CMS\Backend\Tree\Pagetree\ExtdirectTreeDataProvider::class
545 );
546 ExtensionManagementUtility::registerExtDirectComponent(
547 'TYPO3.Components.PageTree.Commands',
548 \TYPO3\CMS\Backend\Tree\Pagetree\ExtdirectTreeCommands::class
549 );
550 ExtensionManagementUtility::registerExtDirectComponent(
551 'TYPO3.Components.PageTree.ContextMenuDataProvider',
552 \TYPO3\CMS\Backend\ContextMenu\Pagetree\Extdirect\ContextMenuConfiguration::class
553 );
554 ExtensionManagementUtility::registerExtDirectComponent(
555 'TYPO3.ExtDirectStateProvider.ExtDirect',
556 \TYPO3\CMS\Backend\InterfaceState\ExtDirect\DataProvider::class
557 );
558 }
559 return $this;
560 }
561
562 /**
563 * Initialize caching framework, and re-initializes it (e.g. in the install tool) by recreating the instances
564 * again despite the Singleton instance
565 *
566 * @return Bootstrap
567 * @internal This is not a public API method, do not use in own extensions
568 */
569 public function initializeCachingFramework()
570 {
571 $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
572 $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
573 GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
574
575 $cacheFactory = new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
576 GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheFactory::class, $cacheFactory);
577
578 $this->setEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $cacheManager);
579 return $this;
580 }
581
582 /**
583 * Set cacheHash options
584 *
585 * @return Bootstrap
586 */
587 protected function setCacheHashOptions()
588 {
589 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] = array(
590 'cachedParametersWhiteList' => GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashOnlyForParameters'], true),
591 'excludedParameters' => GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParameters'], true),
592 'requireCacheHashPresenceParameters' => GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashRequiredParameters'], true)
593 );
594 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty']) === '*') {
595 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludeAllEmptyParameters'] = true;
596 } else {
597 $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParametersIfEmpty'] = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['cHashExcludedParametersIfEmpty'], true);
598 }
599 return $this;
600 }
601
602 /**
603 * Set default timezone
604 *
605 * @return Bootstrap
606 */
607 protected function setDefaultTimezone()
608 {
609 $timeZone = $GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
610 if (empty($timeZone)) {
611 // Time zone from the server environment (TZ env or OS query)
612 $defaultTimeZone = @date_default_timezone_get();
613 if ($defaultTimeZone !== '') {
614 $timeZone = $defaultTimeZone;
615 } else {
616 $timeZone = 'UTC';
617 }
618 }
619 // Set default to avoid E_WARNINGs with PHP > 5.3
620 date_default_timezone_set($timeZone);
621 return $this;
622 }
623
624 /**
625 * Initialize the locales handled by TYPO3
626 *
627 * @return Bootstrap
628 */
629 protected function initializeL10nLocales()
630 {
631 \TYPO3\CMS\Core\Localization\Locales::initialize();
632 return $this;
633 }
634
635 /**
636 * Convert type of "pageNotFound_handling" setting in case it was written as a
637 * string (e.g. if edited in Install Tool)
638 *
639 * @TODO : Remove, if the Install Tool handles such data types correctly
640 * @return Bootstrap
641 */
642 protected function convertPageNotFoundHandlingToBoolean()
643 {
644 if (!strcasecmp($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'], 'TRUE')) {
645 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = true;
646 }
647 return $this;
648 }
649
650 /**
651 * Configure and set up exception and error handling
652 *
653 * @return Bootstrap
654 * @throws \RuntimeException
655 */
656 protected function initializeErrorHandling()
657 {
658 $productionExceptionHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
659 $debugExceptionHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
660
661 $errorHandlerClassName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'];
662 $errorHandlerErrors = $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors'];
663 $exceptionalErrors = $GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
664
665 $displayErrorsSetting = (int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'];
666 switch ($displayErrorsSetting) {
667 case 2:
668 GeneralUtility::deprecationLog('The option "$TYPO3_CONF_VARS[SYS][displayErrors]" is set to "2" which is deprecated as of TYPO3 CMS 7, and will be removed with TYPO3 CMS 8. Please change the value to "-1"');
669 // intentionally fall through
670 case -1:
671 $ipMatchesDevelopmentSystem = GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
672 $exceptionHandlerClassName = $ipMatchesDevelopmentSystem ? $debugExceptionHandlerClassName : $productionExceptionHandlerClassName;
673 $displayErrors = $ipMatchesDevelopmentSystem ? 1 : 0;
674 $exceptionalErrors = $ipMatchesDevelopmentSystem ? $exceptionalErrors : 0;
675 break;
676 case 0:
677 $exceptionHandlerClassName = $productionExceptionHandlerClassName;
678 $displayErrors = 0;
679 break;
680 case 1:
681 $exceptionHandlerClassName = $debugExceptionHandlerClassName;
682 $displayErrors = 1;
683 break;
684 default:
685 // Throw exception if an invalid option is set.
686 throw new \RuntimeException('The option $TYPO3_CONF_VARS[SYS][displayErrors] is not set to "-1", "0" or "1".');
687 }
688 @ini_set('display_errors', $displayErrors);
689
690 if (!empty($errorHandlerClassName)) {
691 // Register an error handler for the given errorHandlerError
692 $errorHandler = GeneralUtility::makeInstance($errorHandlerClassName, $errorHandlerErrors);
693 $errorHandler->setExceptionalErrors($exceptionalErrors);
694 if (is_callable(array($errorHandler, 'setDebugMode'))) {
695 $errorHandler->setDebugMode($displayErrors === 1);
696 }
697 }
698 if (!empty($exceptionHandlerClassName)) {
699 // Registering the exception handler is done in the constructor
700 GeneralUtility::makeInstance($exceptionHandlerClassName);
701 }
702 return $this;
703 }
704
705 /**
706 * Set PHP memory limit depending on value of
707 * $GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit']
708 *
709 * @return Bootstrap
710 */
711 protected function setMemoryLimit()
712 {
713 if ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] > 16) {
714 @ini_set('memory_limit', ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] . 'm'));
715 }
716 return $this;
717 }
718
719 /**
720 * Define TYPO3_REQUESTTYPE* constants
721 * so devs exactly know what type of request it is
722 *
723 * @return Bootstrap
724 */
725 protected function defineTypo3RequestTypes()
726 {
727 define('TYPO3_REQUESTTYPE_FE', 1);
728 define('TYPO3_REQUESTTYPE_BE', 2);
729 define('TYPO3_REQUESTTYPE_CLI', 4);
730 define('TYPO3_REQUESTTYPE_AJAX', 8);
731 define('TYPO3_REQUESTTYPE_INSTALL', 16);
732 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));
733 return $this;
734 }
735
736 /**
737 * Extensions may register new caches, so we set the
738 * global cache array to the manager again at this point
739 *
740 * @return Bootstrap
741 * @internal This is not a public API method, do not use in own extensions
742 */
743 public function setFinalCachingFrameworkCacheConfiguration()
744 {
745 $this->getEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
746 return $this;
747 }
748
749 /**
750 * Define logging and exception constants
751 *
752 * @return Bootstrap
753 * @internal This is not a public API method, do not use in own extensions
754 */
755 public function defineLoggingAndExceptionConstants()
756 {
757 define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
758 define('TYPO3_ERROR_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG']);
759 define('TYPO3_EXCEPTION_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG']);
760 return $this;
761 }
762
763 /**
764 * Unsetting reserved global variables:
765 * Those are set in "ext:core/ext_tables.php" file:
766 *
767 * @return Bootstrap
768 * @internal This is not a public API method, do not use in own extensions
769 */
770 public function unsetReservedGlobalVariables()
771 {
772 unset($GLOBALS['PAGES_TYPES']);
773 unset($GLOBALS['TCA']);
774 unset($GLOBALS['TBE_MODULES']);
775 unset($GLOBALS['TBE_STYLES']);
776 unset($GLOBALS['BE_USER']);
777 // Those set otherwise:
778 unset($GLOBALS['TBE_MODULES_EXT']);
779 unset($GLOBALS['TCA_DESCR']);
780 unset($GLOBALS['LOCAL_LANG']);
781 unset($GLOBALS['TYPO3_AJAX']);
782 return $this;
783 }
784
785 /**
786 * Initialize database connection in $GLOBALS and connect if requested
787 *
788 * @return \TYPO3\CMS\Core\Core\Bootstrap
789 * @internal This is not a public API method, do not use in own extensions
790 */
791 public function initializeTypo3DbGlobal()
792 {
793 /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
794 $databaseConnection = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
795 $databaseConnection->setDatabaseName(TYPO3_db);
796 $databaseConnection->setDatabaseUsername(TYPO3_db_username);
797 $databaseConnection->setDatabasePassword(TYPO3_db_password);
798
799 $databaseHost = TYPO3_db_host;
800 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])) {
801 $databaseConnection->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['port']);
802 } elseif (strpos($databaseHost, ':') > 0) {
803 // @TODO: Find a way to handle this case in the install tool and drop this
804 list($databaseHost, $databasePort) = explode(':', $databaseHost);
805 $databaseConnection->setDatabasePort($databasePort);
806 }
807 if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])) {
808 $databaseConnection->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
809 }
810 $databaseConnection->setDatabaseHost($databaseHost);
811
812 $databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
813
814 if (
815 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'])
816 && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']
817 ) {
818 $databaseConnection->setPersistentDatabaseConnection(true);
819 }
820
821 $isDatabaseHostLocalHost = $databaseHost === 'localhost' || $databaseHost === '127.0.0.1' || $databaseHost === '::1';
822 if (
823 isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress'])
824 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['dbClientCompress']
825 && !$isDatabaseHostLocalHost
826 ) {
827 $databaseConnection->setConnectionCompression(true);
828 }
829
830 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'])) {
831 $commandsAfterConnect = GeneralUtility::trimExplode(
832 LF,
833 str_replace('\' . LF . \'', LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']),
834 true
835 );
836 $databaseConnection->setInitializeCommandsAfterConnect($commandsAfterConnect);
837 }
838
839 $GLOBALS['TYPO3_DB'] = $databaseConnection;
840 // $GLOBALS['TYPO3_DB'] needs to be defined first in order to work for DBAL
841 $GLOBALS['TYPO3_DB']->initialize();
842
843 return $this;
844 }
845
846 /**
847 * Check adminOnly configuration variable and redirects
848 * to an URL in file typo3conf/LOCK_BACKEND or exit the script
849 *
850 * @throws \RuntimeException
851 * @param bool $forceProceeding if this option is set, the bootstrap will proceed even if the user is logged in (usually only needed for special AJAX cases, see AjaxRequestHandler)
852 * @return Bootstrap
853 * @internal This is not a public API method, do not use in own extensions
854 */
855 public function checkLockedBackendAndRedirectOrDie($forceProceeding = false)
856 {
857 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['adminOnly'] < 0) {
858 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);
859 }
860 if (@is_file(PATH_typo3conf . 'LOCK_BACKEND') && $forceProceeding === false) {
861 $fileContent = GeneralUtility::getUrl(PATH_typo3conf . 'LOCK_BACKEND');
862 if ($fileContent) {
863 header('Location: ' . $fileContent);
864 } else {
865 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);
866 }
867 die;
868 }
869 return $this;
870 }
871
872 /**
873 * Compare client IP with IPmaskList and exit the script run
874 * if the client is not allowed to access the backend
875 *
876 * @return Bootstrap
877 * @internal This is not a public API method, do not use in own extensions
878 * @throws \RuntimeException
879 */
880 public function checkBackendIpOrDie()
881 {
882 if (trim($GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
883 if (!GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['BE']['IPmaskList'])) {
884 throw new \RuntimeException('TYPO3 Backend access denied: The IP address of your client does not match the list of allowed IP addresses.', 1389265900);
885 }
886 }
887 return $this;
888 }
889
890 /**
891 * Check lockSSL configuration variable and redirect
892 * to https version of the backend if needed
893 *
894 * @return Bootstrap
895 * @internal This is not a public API method, do not use in own extensions
896 * @throws \RuntimeException
897 */
898 public function checkSslBackendAndRedirectIfNeeded()
899 {
900 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL']) {
901 if (!GeneralUtility::getIndpEnv('TYPO3_SSL')) {
902 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] === 2) {
903 if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort']) {
904 $sslPortSuffix = ':' . (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSLPort'];
905 } else {
906 $sslPortSuffix = '';
907 }
908 list(, $url) = explode('://', GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir, 2);
909 list($server, $address) = explode('/', $url, 2);
910 header('Location: https://' . $server . $sslPortSuffix . '/' . $address);
911 die;
912 } else {
913 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);
914 }
915 }
916 }
917 return $this;
918 }
919
920 /**
921 * Load TCA for frontend
922 *
923 * This method is *only* executed in frontend scope. The idea is to execute the
924 * whole TCA and ext_tables (which manipulate TCA) on first frontend access,
925 * and then cache the full TCA on disk to be used for the next run again.
926 *
927 * This way, ext_tables.php ist not executed every time, but $GLOBALS['TCA']
928 * is still always there.
929 *
930 * @return Bootstrap
931 * @internal This is not a public API method, do not use in own extensions
932 */
933 public function loadCachedTca()
934 {
935 $cacheIdentifier = 'tca_fe_' . sha1((TYPO3_version . PATH_site . 'tca_fe'));
936 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
937 $codeCache = $this->getEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_core');
938 if ($codeCache->has($cacheIdentifier)) {
939 // substr is necessary, because the php frontend wraps php code around the cache value
940 $GLOBALS['TCA'] = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
941 } else {
942 $this->loadExtensionTables(true);
943 $codeCache->set($cacheIdentifier, serialize($GLOBALS['TCA']));
944 }
945 return $this;
946 }
947
948 /**
949 * Load ext_tables and friends.
950 *
951 * This will mainly set up $TCA and several other global arrays
952 * through API's like extMgm.
953 * Executes ext_tables.php files of loaded extensions or the
954 * according cache file if exists.
955 *
956 * @param bool $allowCaching True, if reading compiled ext_tables file from cache is allowed
957 * @return Bootstrap
958 * @internal This is not a public API method, do not use in own extensions
959 */
960 public function loadExtensionTables($allowCaching = true)
961 {
962 ExtensionManagementUtility::loadBaseTca($allowCaching);
963 ExtensionManagementUtility::loadExtTables($allowCaching);
964 $this->runExtTablesPostProcessingHooks();
965 return $this;
966 }
967
968 /**
969 * Check for registered ext tables hooks and run them
970 *
971 * @throws \UnexpectedValueException
972 * @return void
973 */
974 protected function runExtTablesPostProcessingHooks()
975 {
976 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'])) {
977 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] as $classReference) {
978 /** @var $hookObject \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface */
979 $hookObject = GeneralUtility::getUserObj($classReference);
980 if (!$hookObject instanceof \TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
981 throw new \UnexpectedValueException(
982 '$hookObject "' . $classReference . '" must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface',
983 1320585902
984 );
985 }
986 $hookObject->processData();
987 }
988 }
989 }
990
991 /**
992 * Initialize the Routing for the TYPO3 Backend
993 * Loads all routes registered inside all packages and stores them inside the Router
994 *
995 * @return Bootstrap
996 * @internal This is not a public API method, do not use in own extensions
997 */
998 public function initializeBackendRouter()
999 {
1000 $packageManager = $this->getEarlyInstance(\TYPO3\CMS\Core\Package\PackageManager::class);
1001
1002 // See if the Routes.php from all active packages have been built together already
1003 $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1((TYPO3_version . PATH_site . 'BackendRoutesFromPackages'));
1004
1005 /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend */
1006 $codeCache = $this->getEarlyInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_core');
1007 $routesFromPackages = array();
1008 if ($codeCache->has($cacheIdentifier)) {
1009 // substr is necessary, because the php frontend wraps php code around the cache value
1010 $routesFromPackages = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
1011 } else {
1012 // Loop over all packages and check for a Configuration/Backend/Routes.php file
1013 $packages = $packageManager->getActivePackages();
1014 foreach ($packages as $package) {
1015 $routesFileNameForPackage = $package->getPackagePath() . 'Configuration/Backend/Routes.php';
1016 if (file_exists($routesFileNameForPackage)) {
1017 $definedRoutesInPackage = require $routesFileNameForPackage;
1018 if (is_array($definedRoutesInPackage)) {
1019 $routesFromPackages += $definedRoutesInPackage;
1020 }
1021 }
1022 $routesFileNameForPackage = $package->getPackagePath() . 'Configuration/Backend/AjaxRoutes.php';
1023 if (file_exists($routesFileNameForPackage)) {
1024 $definedRoutesInPackage = require $routesFileNameForPackage;
1025 if (is_array($definedRoutesInPackage)) {
1026 foreach ($definedRoutesInPackage as $routeIdentifier => $routeOptions) {
1027 // prefix the route with "ajax_" as "namespace"
1028 $routeOptions['path'] = '/ajax' . $routeOptions['path'];
1029 $routesFromPackages['ajax_' . $routeIdentifier] = $routeOptions;
1030 $routesFromPackages['ajax_' . $routeIdentifier]['ajax'] = true;
1031 }
1032 }
1033 }
1034 }
1035 // Store the data from all packages in the cache
1036 $codeCache->set($cacheIdentifier, serialize($routesFromPackages));
1037 }
1038
1039 // Build Route objects from the data
1040 $router = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\Router::class);
1041 foreach ($routesFromPackages as $name => $options) {
1042 $path = $options['path'];
1043 unset($options['path']);
1044 $route = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\Route::class, $path, $options);
1045 $router->addRoute($name, $route);
1046 }
1047 return $this;
1048 }
1049
1050 /**
1051 * Initialize backend user object in globals
1052 *
1053 * @return Bootstrap
1054 * @internal This is not a public API method, do not use in own extensions
1055 */
1056 public function initializeBackendUser()
1057 {
1058 /** @var $backendUser \TYPO3\CMS\Core\Authentication\BackendUserAuthentication */
1059 $backendUser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class);
1060 $backendUser->warningEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
1061 $backendUser->lockIP = $GLOBALS['TYPO3_CONF_VARS']['BE']['lockIP'];
1062 $backendUser->auth_timeout_field = (int)$GLOBALS['TYPO3_CONF_VARS']['BE']['sessionTimeout'];
1063 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
1064 $backendUser->dontSetCookie = true;
1065 }
1066 // The global must be available very early, because methods below
1067 // might trigger code which relies on it. See: #45625
1068 $GLOBALS['BE_USER'] = $backendUser;
1069 $backendUser->start();
1070 return $this;
1071 }
1072
1073 /**
1074 * Initializes and ensures authenticated access
1075 *
1076 * @internal This is not a public API method, do not use in own extensions
1077 * @param bool $proceedIfNoUserIsLoggedIn if set to TRUE, no forced redirect to the login page will be done
1078 * @return \TYPO3\CMS\Core\Core\Bootstrap
1079 */
1080 public function initializeBackendAuthentication($proceedIfNoUserIsLoggedIn = false)
1081 {
1082 $GLOBALS['BE_USER']->backendCheckLogin($proceedIfNoUserIsLoggedIn);
1083 return $this;
1084 }
1085
1086 /**
1087 * Initialize language object
1088 *
1089 * @return Bootstrap
1090 * @internal This is not a public API method, do not use in own extensions
1091 */
1092 public function initializeLanguageObject()
1093 {
1094 /** @var $GLOBALS['LANG'] \TYPO3\CMS\Lang\LanguageService */
1095 $GLOBALS['LANG'] = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class);
1096 $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
1097 return $this;
1098 }
1099
1100 /**
1101 * Throw away all output that may have happened during bootstrapping by weird extensions
1102 *
1103 * @return Bootstrap
1104 * @internal This is not a public API method, do not use in own extensions
1105 */
1106 public function endOutputBufferingAndCleanPreviousOutput()
1107 {
1108 ob_clean();
1109 return $this;
1110 }
1111
1112 /**
1113 * Initialize output compression if configured
1114 *
1115 * @return Bootstrap
1116 * @internal This is not a public API method, do not use in own extensions
1117 */
1118 public function initializeOutputCompression()
1119 {
1120 if (extension_loaded('zlib') && $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']) {
1121 if (MathUtility::canBeInterpretedAsInteger($GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'])) {
1122 @ini_set('zlib.output_compression_level', $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel']);
1123 }
1124 ob_start('ob_gzhandler');
1125 }
1126 return $this;
1127 }
1128
1129 /**
1130 * Send HTTP headers if configured
1131 *
1132 * @return Bootstrap
1133 * @internal This is not a public API method, do not use in own extensions
1134 */
1135 public function sendHttpHeaders()
1136 {
1137 if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers']) && is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'])) {
1138 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['HTTP']['Response']['Headers'] as $header) {
1139 header($header);
1140 }
1141 }
1142 return $this;
1143 }
1144
1145 /**
1146 * Things that should be performed to shut down the framework.
1147 * This method is called in all important scripts for a clean
1148 * shut down of the system.
1149 *
1150 * @return Bootstrap
1151 * @internal This is not a public API method, do not use in own extensions
1152 */
1153 public function shutdown()
1154 {
1155 $this->sendResponse();
1156 return $this;
1157 }
1158
1159 /**
1160 * Provides an instance of "template" for backend-modules to
1161 * work with.
1162 *
1163 * @return Bootstrap
1164 * @internal This is not a public API method, do not use in own extensions
1165 */
1166 public function initializeBackendTemplate()
1167 {
1168 $GLOBALS['TBE_TEMPLATE'] = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
1169 return $this;
1170 }
1171 }