‪TYPO3CMS  9.5
Bootstrap.php
Go to the documentation of this file.
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 Composer\Autoload\ClassLoader;
18 use Doctrine\Common\Annotations\AnnotationReader;
19 use Doctrine\Common\Annotations\AnnotationRegistry;
20 use Psr\Container\ContainerInterface;
21 use Psr\Container\NotFoundExceptionInterface;
24 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
30 use TYPO3\CMS\Core\Package\PackageManager;
34 use TYPO3\PharStreamWrapper\Behavior;
35 use TYPO3\PharStreamWrapper\Manager;
36 use TYPO3\PharStreamWrapper\PharStreamWrapper;
37 
50 {
54  protected static ‪$instance;
55 
59  protected ‪$earlyInstances = [];
60 
64  protected ‪$limbo = false;
65 
69  protected function ‪__construct()
70  {
71  }
72 
81  public static function ‪init(
82  ClassLoader $classLoader,
83  bool $failsafe = false
84  ): ContainerInterface {
85  $requestId = substr(md5(uniqid('', true)), 0, 13);
86 
87  static::initializeClassLoader($classLoader);
90  }
91 
92  static::startOutputBuffering();
93 
94  $configurationManager = static::createConfigurationManager();
95  if (!static::checkIfEssentialConfigurationExists($configurationManager)) {
96  $failsafe = true;
97  }
98  static::populateLocalConfiguration($configurationManager);
99 
100  $logManager = new ‪LogManager($requestId);
101  // LogManager is used by the core ErrorHandler (using GeneralUtility::makeInstance),
102  // therefore we have to push the LogManager to GeneralUtility, to ensure the requestId is set
103  GeneralUtility::setSingletonInstance(LogManager::class, $logManager);
104 
105  static::initializeErrorHandling();
106  static::initializeIO();
107 
108  $cacheManager = static::createCacheManager($failsafe ? true : false);
109  $coreCache = $cacheManager->getCache('cache_core');
110  $assetsCache = $cacheManager->getCache('assets');
111  $cacheManager->setLimbo(true);
112  $packageManager = static::createPackageManager(
113  $failsafe ? FailsafePackageManager::class : PackageManager::class,
114  $coreCache
115  );
116 
117  // Push singleton instances to GeneralUtility and ExtensionManagementUtility
118  // They should be fetched through a container (later) but currently a PackageManager
119  // singleton instance is required by PackageManager->activePackageDuringRuntime
120  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager);
121  GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);
123 
124  static::initializeRuntimeActivatedPackagesFromConfiguration($packageManager);
125 
126  static::setDefaultTimeZone();
128  static::setMemoryLimit();
129 
130  // Create (to be deprecated) bootstrap instance with (to be deprecated) early instances
131  static::$instance = new static();
132  static::$instance->earlyInstances = [
133  ClassLoader::class => $classLoader,
134  ConfigurationManager::class => $configurationManager,
135  CacheManager::class => $cacheManager,
136  PackageManager::class => $packageManager,
137  ];
138 
139  if (!$failsafe) {
140  ‪IconRegistry::setCache($assetsCache);
141  ‪PageRenderer::setCache($assetsCache);
142  static::loadTypo3LoadedExtAndExtLocalconf(true, $coreCache);
143  static::setFinalCachingFrameworkCacheConfiguration($cacheManager);
144  static::unsetReservedGlobalVariables();
145  static::loadBaseTca(true, $coreCache);
146  static::checkEncryptionKey();
147  }
148  $cacheManager->setLimbo(false);
149 
150  $defaultContainerEntries = [
151  ClassLoader::class => $classLoader,
152  'request.id' => $requestId,
153  ConfigurationManager::class => $configurationManager,
154  LogManager::class => $logManager,
155  CacheManager::class => $cacheManager,
156  PackageManager::class => $packageManager,
157  Locales::class => ‪$locales,
158  ];
159 
160  return new class($defaultContainerEntries) implements ContainerInterface {
164  private $entries;
165 
169  public function ‪__construct(array $entries)
170  {
171  $this->entries = $entries;
172  }
173 
178  public function has($id)
179  {
180  if (isset($this->entries[$id])) {
181  return true;
182  }
183 
184  switch ($id) {
185  case \TYPO3\CMS\Frontend\Http\Application::class:
186  case \TYPO3\CMS\Backend\Http\Application::class:
187  case \TYPO3\CMS\Install\Http\Application::class:
188  case \TYPO3\CMS\Core\Console\CommandApplication::class:
189  return true;
190  }
191 
192  return false;
193  }
194 
202  public function get($id)
203  {
204  $entry = null;
205 
206  if (isset($this->entries[$id])) {
207  return $this->entries[$id];
208  }
209 
210  switch ($id) {
211  case \TYPO3\CMS\Frontend\Http\Application::class:
212  case \TYPO3\CMS\Backend\Http\Application::class:
213  $entry = new $id($this->get(ConfigurationManager::class));
214  break;
215  case \TYPO3\CMS\Install\Http\Application::class:
216  $entry = new $id(
217  GeneralUtility::makeInstance(\‪TYPO3\CMS\Install\Http\RequestHandler::class, $this->get(ConfigurationManager::class)),
218  GeneralUtility::makeInstance(\‪TYPO3\CMS\Install\Http\InstallerRequestHandler::class)
219  );
220  break;
221  case \TYPO3\CMS\Core\Console\CommandApplication::class:
222  $entry = new $id;
223  break;
224  default:
225  throw new class($id . ' not found', 1518638338) extends \‪Exception implements NotFoundExceptionInterface {
226  };
227  break;
228  }
229 
230  $this->entries[$id] = $entry;
231 
232  return $entry;
233  }
234  };
235  }
236 
241  public static function ‪usesComposerClassLoading()
242  {
243  trigger_error('Bootstrap::usesComposerClassLoading() will be removed in TYPO3 v10.0. Use Environment::isComposerMode() instead.', E_USER_DEPRECATED);
245  }
246 
250  protected function ‪__clone()
251  {
252  }
253 
261  public static function ‪getInstance()
262  {
263  if (static::$instance === null) {
264  self::$instance = new static();
265  self::$instance->‪defineTypo3RequestTypes();
266  $requestId = substr(md5(uniqid('', true)), 0, 13);
267  GeneralUtility::setSingletonInstance(LogManager::class, new ‪LogManager($requestId));
268  }
269  return static::$instance;
270  }
271 
277  public static function ‪createApplicationContext(): ApplicationContext
278  {
279  $applicationContext = getenv('TYPO3_CONTEXT') ?: (getenv('REDIRECT_TYPO3_CONTEXT') ?: 'Production');
280 
281  return new ApplicationContext($applicationContext);
282  }
283 
291  public static function ‪startOutputBuffering()
292  {
293  ob_start();
294  return static::$instance;
295  }
296 
306  public function ‪configure()
307  {
308  $this->‪startOutputBuffering()
309  ->‪loadConfigurationAndInitialize(true, \‪TYPO3\CMS\Core\Package\PackageManager::class, true)
313  ->‪loadBaseTca()
315  return $this;
316  }
317 
329  public static function ‪baseSetup($entryPointLevel = null)
330  {
331  if (!defined('TYPO3_REQUESTTYPE')) {
332  throw new \RuntimeException('No Request Type was set, TYPO3 does not know in which context it is run.', 1450561838);
333  }
334  // @deprecated: remove this code block in TYPO3 v10.0
335  if (GeneralUtility::getApplicationContext() === null) {
337  }
340  }
341  return static::$instance;
342  }
343 
351  public static function ‪initializeClassLoader(ClassLoader $classLoader)
352  {
354 
356  AnnotationRegistry::registerLoader([$classLoader, 'loadClass']);
357 
358  /*
359  * All annotations defined by and for Extbase need to be
360  * ignored during their deprecation. Later, their usage may and
361  * should throw an Exception
362  */
363  AnnotationReader::addGlobalIgnoredName('inject');
364  AnnotationReader::addGlobalIgnoredName('transient');
365  AnnotationReader::addGlobalIgnoredName('lazy');
366  AnnotationReader::addGlobalIgnoredName('validate');
367  AnnotationReader::addGlobalIgnoredName('cascade');
368  AnnotationReader::addGlobalIgnoredName('ignorevalidation');
369  AnnotationReader::addGlobalIgnoredName('cli');
370  AnnotationReader::addGlobalIgnoredName('flushesCaches');
371  AnnotationReader::addGlobalIgnoredName('uuid');
372  AnnotationReader::addGlobalIgnoredName('identity');
373 
374  // Annotations used in unit tests
375  AnnotationReader::addGlobalIgnoredName('test');
376 
377  // Annotations that control the extension scanner
378  AnnotationReader::addGlobalIgnoredName('extensionScannerIgnoreFile');
379  AnnotationReader::addGlobalIgnoredName('extensionScannerIgnoreLine');
380 
381  return static::$instance;
382  }
383 
392  protected static function ‪checkIfEssentialConfigurationExists(ConfigurationManager $configurationManager = null): bool
393  {
394  if ($configurationManager === null) {
395  // @deprecated A configurationManager instance needs to be handed into Bootstrap::checkIfEssentialConfigurationExists and will become mandatory in TYPO3 v10.0
396  $configurationManager = new ConfigurationManager;
397  static::$instance->setEarlyInstance(ConfigurationManager::class, $configurationManager);
398  }
399  return file_exists($configurationManager->getLocalConfigurationFileLocation())
400  && file_exists(‪Environment::getLegacyConfigPath() . '/PackageStates.php');
401  }
402 
413  public function ‪setEarlyInstance($objectName, ‪$instance)
414  {
415  $this->earlyInstances[$objectName] = ‪$instance;
416  }
417 
427  public function ‪getEarlyInstance($objectName)
428  {
429  if (!isset($this->earlyInstances[$objectName])) {
430  throw new \TYPO3\CMS\Core\Exception('Unknown early instance "' . $objectName . '"', 1365167380);
431  }
432  return $this->earlyInstances[$objectName];
433  }
434 
442  public function ‪getEarlyInstances()
443  {
444  trigger_error('Bootstrap->getEarlyInstances() will be removed in TYPO3 v10.0. Use a simple singleton instance instead.', E_USER_DEPRECATED);
446  }
447 
460  public static function ‪loadConfigurationAndInitialize(
461  $allowCaching = true,
462  $packageManagerClassName = \‪TYPO3\CMS\Core\Package\PackageManager::class,
463  $isInternalCall = false
464  ) {
465  if (!$isInternalCall) {
466  // Suppress duplicate deprecation calls
467  trigger_error('Bootstrap::loadConfigurationAndInitialize() will removed in TYPO3 v10.0.', E_USER_DEPRECATED);
468  }
469 
470  $configurationManager = static::createConfigurationManager();
471  static::populateLocalConfiguration($configurationManager);
472  static::initializeErrorHandling();
473 
474  $cacheManager = static::createCacheManager(!$allowCaching);
475  $packageManager = static::createPackageManager($packageManagerClassName, $cacheManager->getCache('cache_core'));
476 
477  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager);
478  GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);
480 
481  static::initializeRuntimeActivatedPackagesFromConfiguration($packageManager);
482  static::setDefaultTimezone();
484  static::setMemoryLimit();
485  return static::$instance;
486  }
487 
497  public static function ‪createPackageManager($packageManagerClassName, FrontendInterface $coreCache): PackageManager
498  {
499  $dependencyOrderingService = GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Service\DependencyOrderingService::class);
501  $packageManager = new $packageManagerClassName($dependencyOrderingService);
502  $packageManager->injectCoreCache($coreCache);
503  $packageManager->initialize();
504 
505  return $packageManager;
506  }
507 
517  public function ‪initializePackageManagement($packageManagerClassName)
518  {
519  trigger_error('Bootstrap->initializePackageManagement() will be removed in TYPO3 v10.0. Use createPackageManager() instead.', E_USER_DEPRECATED);
520  $packageManager = static::createPackageManager(
521  $packageManagerClassName,
522  GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_core')
523  );
524  GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);
526  $this->‪setEarlyInstance(PackageManager::class, $packageManager);
527 
528  return $this;
529  }
530 
537  protected static function ‪initializeRuntimeActivatedPackagesFromConfiguration(PackageManager $packageManager)
538  {
539  $packages = ‪$GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages'] ?? [];
540  if (!empty($packages)) {
541  foreach ($packages as $runtimeAddedPackageKey) {
542  $packageManager->activatePackageDuringRuntime($runtimeAddedPackageKey);
543  }
544  }
545  }
546 
555  public static function ‪loadTypo3LoadedExtAndExtLocalconf($allowCaching = true, FrontendInterface $coreCache = null)
556  {
557  if ($allowCaching) {
558  $coreCache = $coreCache ?? GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_core');
559  }
560  ‪ExtensionManagementUtility::loadExtLocalconf($allowCaching, $coreCache);
561  return static::$instance;
562  }
563 
570  public static function ‪createConfigurationManager(): ConfigurationManager
571  {
572  return new ConfigurationManager();
573  }
574 
583  protected static function ‪populateLocalConfiguration(ConfigurationManager $configurationManager = null)
584  {
585  if ($configurationManager === null) {
586  $configurationManager = new ConfigurationManager();
587  static::$instance->setEarlyInstance(ConfigurationManager::class, $configurationManager);
588  }
589 
590  $configurationManager->exportConfiguration();
591 
592  return static::$instance;
593  }
594 
603  public static function ‪disableCoreCache()
604  {
605  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['backend']
606  = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class;
607  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_core']['options']);
608  return static::$instance;
609  }
610 
619  public static function ‪createCacheManager(bool $disableCaching = false): CacheManager
620  {
621  $cacheManager = new CacheManager($disableCaching);
622  $cacheManager->setCacheConfigurations(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
623  return $cacheManager;
624  }
625 
635  public function ‪initializeCachingFramework(bool $allowCaching = true)
636  {
637  $cacheManager = static::createCacheManager(!$allowCaching);
638  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager);
639  $this->‪setEarlyInstance(CacheManager::class, $cacheManager);
640  return $this;
641  }
642 
646  protected static function ‪setDefaultTimezone()
647  {
648  $timeZone = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['phpTimeZone'];
649  if (empty($timeZone)) {
650  // Time zone from the server environment (TZ env or OS query)
651  $defaultTimeZone = @date_default_timezone_get();
652  if ($defaultTimeZone !== '') {
653  $timeZone = $defaultTimeZone;
654  } else {
655  $timeZone = 'UTC';
656  }
657  }
658  // Set default to avoid E_WARNINGs with PHP > 5.3
659  date_default_timezone_set($timeZone);
660  }
661 
667  protected static function ‪initializeErrorHandling()
668  {
669  $productionExceptionHandlerClassName = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'];
670  $debugExceptionHandlerClassName = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'];
671 
672  $errorHandlerClassName = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'];
673  $errorHandlerErrors = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors'] | E_USER_DEPRECATED;
674  $exceptionalErrors = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'];
675 
676  $displayErrorsSetting = (int)‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'];
677  switch ($displayErrorsSetting) {
678  case -1:
679  $ipMatchesDevelopmentSystem = GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
680  $exceptionHandlerClassName = $ipMatchesDevelopmentSystem ? $debugExceptionHandlerClassName : $productionExceptionHandlerClassName;
681  $displayErrors = $ipMatchesDevelopmentSystem ? 1 : 0;
682  $exceptionalErrors = $ipMatchesDevelopmentSystem ? $exceptionalErrors : 0;
683  break;
684  case 0:
685  $exceptionHandlerClassName = $productionExceptionHandlerClassName;
686  $displayErrors = 0;
687  break;
688  case 1:
689  $exceptionHandlerClassName = $debugExceptionHandlerClassName;
690  $displayErrors = 1;
691  break;
692  default:
693  if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
694  // Throw exception if an invalid option is set.
695  throw new \RuntimeException(
696  'The option $TYPO3_CONF_VARS[SYS][displayErrors] is not set to "-1", "0" or "1".',
697  1476046290
698  );
699  }
700  }
701  @ini_set('display_errors', (string)$displayErrors);
702 
703  if (!empty($errorHandlerClassName)) {
704  // Register an error handler for the given errorHandlerError
705  $errorHandler = GeneralUtility::makeInstance($errorHandlerClassName, $errorHandlerErrors);
706  $errorHandler->setExceptionalErrors($exceptionalErrors);
707  if (is_callable([$errorHandler, 'setDebugMode'])) {
708  $errorHandler->setDebugMode($displayErrors === 1);
709  }
710  if (is_callable([$errorHandler, 'registerErrorHandler'])) {
711  $errorHandler->registerErrorHandler();
712  }
713  }
714  if (!empty($exceptionHandlerClassName)) {
715  // Registering the exception handler is done in the constructor
716  GeneralUtility::makeInstance($exceptionHandlerClassName);
717  }
718  }
719 
723  protected static function ‪initializeIO()
724  {
725  if (in_array('phar', stream_get_wrappers())) {
726  // destroy and re-initialize PharStreamWrapper for TYPO3 core
727  Manager::destroy();
728  Manager::initialize(
729  (new Behavior())
730  ->withAssertion(new ‪PharStreamWrapperInterceptor())
731  );
732 
733  stream_wrapper_unregister('phar');
734  stream_wrapper_register('phar', PharStreamWrapper::class);
735  }
736  }
737 
742  protected static function ‪setMemoryLimit()
743  {
744  if ((int)‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] > 16) {
745  @ini_set('memory_limit', (string)((int)‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['setMemoryLimit'] . 'm'));
746  }
747  }
748 
759  protected function ‪defineTypo3RequestTypes()
760  {
761  if (defined('TYPO3_REQUESTTYPE_FE')) {
762  return;
763  }
764  define('TYPO3_REQUESTTYPE_FE', 1);
765  define('TYPO3_REQUESTTYPE_BE', 2);
766  define('TYPO3_REQUESTTYPE_CLI', 4);
767  define('TYPO3_REQUESTTYPE_AJAX', 8);
768  define('TYPO3_REQUESTTYPE_INSTALL', 16);
769  }
770 
779  public function ‪setRequestType($requestType)
780  {
781  if (defined('TYPO3_REQUESTTYPE')) {
782  throw new \RuntimeException('TYPO3_REQUESTTYPE has already been set, cannot be called multiple times', 1450561878);
783  }
784  define('TYPO3_REQUESTTYPE', $requestType);
785  return $this;
786  }
787 
796  protected static function ‪setFinalCachingFrameworkCacheConfiguration(CacheManager $cacheManager = null)
797  {
798  if ($cacheManager === null) {
799  $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
800  }
801  $cacheManager->setCacheConfigurations(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
802  return static::$instance;
803  }
804 
812  public static function ‪unsetReservedGlobalVariables()
813  {
814  unset(‪$GLOBALS['PAGES_TYPES']);
815  unset(‪$GLOBALS['TCA']);
816  unset(‪$GLOBALS['TBE_MODULES']);
817  unset(‪$GLOBALS['TBE_STYLES']);
818  unset(‪$GLOBALS['BE_USER']);
819  // Those set otherwise:
820  unset(‪$GLOBALS['TBE_MODULES_EXT']);
821  unset(‪$GLOBALS['TCA_DESCR']);
822  unset(‪$GLOBALS['LOCAL_LANG']);
823  return static::$instance;
824  }
825 
836  public static function ‪loadBaseTca(bool $allowCaching = true, FrontendInterface $coreCache = null)
837  {
838  if ($allowCaching) {
839  $coreCache = $coreCache ?? GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_core');
840  }
841  ‪ExtensionManagementUtility::loadBaseTca($allowCaching, $coreCache);
842  return static::$instance;
843  }
844 
848  protected static function ‪checkEncryptionKey()
849  {
850  if (empty(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
851  throw new \RuntimeException(
852  'TYPO3 Encryption is empty. $GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'encryptionKey\'] needs to be set for TYPO3 to work securely',
853  1502987245
854  );
855  }
856  }
857 
868  public static function ‪loadExtTables(bool $allowCaching = true)
869  {
871  static::runExtTablesPostProcessingHooks();
872  return static::$instance;
873  }
874 
880  protected static function ‪runExtTablesPostProcessingHooks()
881  {
882  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'] ?? [] as $className) {
884  $hookObject = GeneralUtility::makeInstance($className);
885  if (!$hookObject instanceof \‪TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface) {
886  throw new \UnexpectedValueException(
887  '$hookObject "' . $className . '" must implement interface TYPO3\\CMS\\Core\\Database\\TableConfigurationPostProcessingHookInterface',
888  1320585902
889  );
890  }
891  $hookObject->processData();
892  }
893  }
894 
902  public static function ‪initializeBackendRouter()
903  {
904  // See if the Routes.php from all active packages have been built together already
905  $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1(TYPO3_version . ‪Environment::getProjectPath() . 'BackendRoutesFromPackages');
906 
908  $codeCache = GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_core');
909  $routesFromPackages = [];
910  if ($codeCache->has($cacheIdentifier)) {
911  // substr is necessary, because the php frontend wraps php code around the cache value
912  $routesFromPackages = unserialize(substr($codeCache->get($cacheIdentifier), 6, -2));
913  } else {
914  // Loop over all packages and check for a Configuration/Backend/Routes.php file
915  $packageManager = GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Package\PackageManager::class);
916  $packages = $packageManager->getActivePackages();
917  foreach ($packages as $package) {
918  $routesFileNameForPackage = $package->getPackagePath() . 'Configuration/Backend/Routes.php';
919  if (file_exists($routesFileNameForPackage)) {
920  $definedRoutesInPackage = require $routesFileNameForPackage;
921  if (is_array($definedRoutesInPackage)) {
922  $routesFromPackages = array_merge($routesFromPackages, $definedRoutesInPackage);
923  }
924  }
925  $routesFileNameForPackage = $package->getPackagePath() . 'Configuration/Backend/AjaxRoutes.php';
926  if (file_exists($routesFileNameForPackage)) {
927  $definedRoutesInPackage = require $routesFileNameForPackage;
928  if (is_array($definedRoutesInPackage)) {
929  foreach ($definedRoutesInPackage as $routeIdentifier => $routeOptions) {
930  // prefix the route with "ajax_" as "namespace"
931  $routeOptions['path'] = '/ajax' . $routeOptions['path'];
932  $routesFromPackages['ajax_' . $routeIdentifier] = $routeOptions;
933  $routesFromPackages['ajax_' . $routeIdentifier]['ajax'] = true;
934  }
935  }
936  }
937  }
938  // Store the data from all packages in the cache
939  $codeCache->set($cacheIdentifier, serialize($routesFromPackages));
940  }
941 
942  // Build Route objects from the data
943  $router = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\Router::class);
944  foreach ($routesFromPackages as $name => $options) {
945  $path = $options['path'];
946  unset($options['path']);
947  $route = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\Route::class, $path, $options);
948  $router->addRoute($name, $route);
949  }
950  return static::$instance;
951  }
952 
960  public static function ‪initializeBackendUser($className = \‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)
961  {
963  $backendUser = GeneralUtility::makeInstance($className);
964  // The global must be available very early, because methods below
965  // might trigger code which relies on it. See: #45625
966  ‪$GLOBALS['BE_USER'] = $backendUser;
967  $backendUser->start();
968  return static::$instance;
969  }
970 
978  public static function ‪initializeBackendAuthentication($proceedIfNoUserIsLoggedIn = false)
979  {
980  ‪$GLOBALS['BE_USER']->backendCheckLogin($proceedIfNoUserIsLoggedIn);
981  return static::$instance;
982  }
983 
990  public static function ‪initializeLanguageObject()
991  {
993  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Localization\LanguageService::class);
994  ‪$GLOBALS['LANG']->init(‪$GLOBALS['BE_USER']->uc['lang']);
995  return static::$instance;
996  }
997 
1007  public static function ‪__callStatic($methodName, array $arguments)
1008  {
1009  switch ($methodName) {
1010  case 'checkIfEssentialConfigurationExists':
1011  case 'setFinalCachingFrameworkCacheConfiguration':
1012  case 'populateLocalConfiguration':
1013  return call_user_func_array([self::class, $methodName], $arguments);
1014  default:
1015  throw new \Error(sprintf('Call to undefined method "%s"', $methodName), 1534156090);
1016  }
1017  }
1018 
1028  public function ‪__call($methodName, array $arguments)
1029  {
1030  return ‪self::__callStatic($methodName, $arguments);
1031  }
1032 }
‪TYPO3\CMS\Core\Core\Bootstrap\initializeIO
‪static initializeIO()
Definition: Bootstrap.php:719
‪TYPO3\CMS\Core\Core\Bootstrap\loadBaseTca
‪static Bootstrap null loadBaseTca(bool $allowCaching=true, FrontendInterface $coreCache=null)
Definition: Bootstrap.php:832
‪TYPO3\CMS\Core\Core\Bootstrap\unsetReservedGlobalVariables
‪static Bootstrap null unsetReservedGlobalVariables()
Definition: Bootstrap.php:808
‪TYPO3\CMS\Core\Localization\Locales\initialize
‪static Locales initialize()
Definition: Locales.php:135
‪TYPO3\CMS\Core\Package\FailsafePackageManager
Definition: FailsafePackageManager.php:23
‪TYPO3\CMS\Core\Core\Bootstrap\$earlyInstances
‪array $earlyInstances
Definition: Bootstrap.php:57
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:36
‪TYPO3\CMS\Core\Core\Bootstrap\$instance
‪static TYPO3 CMS Core Core Bootstrap $instance
Definition: Bootstrap.php:53
‪TYPO3\CMS\Core\Core\Bootstrap\initializeRuntimeActivatedPackagesFromConfiguration
‪static initializeRuntimeActivatedPackagesFromConfiguration(PackageManager $packageManager)
Definition: Bootstrap.php:533
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Core\Core\Bootstrap\defineTypo3RequestTypes
‪defineTypo3RequestTypes()
Definition: Bootstrap.php:755
‪TYPO3
‪TYPO3\CMS\Core\IO\PharStreamWrapperInterceptor
Definition: PharStreamWrapperInterceptor.php:26
‪TYPO3\CMS\Core\Core\ClassLoadingInformation\isClassLoadingInformationAvailable
‪static bool isClassLoadingInformationAvailable()
Definition: ClassLoadingInformation.php:79
‪TYPO3\CMS\Core\Core\Bootstrap\initializeClassLoader
‪static Bootstrap initializeClassLoader(ClassLoader $classLoader)
Definition: Bootstrap.php:347
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendRouter
‪static Bootstrap null initializeBackendRouter()
Definition: Bootstrap.php:898
‪TYPO3\CMS\Core\Localization\Locales
Definition: Locales.php:29
‪TYPO3\CMS\Core\Core\Bootstrap\__clone
‪__clone()
Definition: Bootstrap.php:246
‪TYPO3\CMS\Core\Core\Bootstrap\setEarlyInstance
‪setEarlyInstance($objectName, $instance)
Definition: Bootstrap.php:409
‪TYPO3\CMS\Core\Core\Bootstrap\getInstance
‪static Bootstrap getInstance()
Definition: Bootstrap.php:257
‪TYPO3\CMS\Core\Core\Bootstrap\checkEncryptionKey
‪static checkEncryptionKey()
Definition: Bootstrap.php:844
‪TYPO3\CMS\Core\Core\Bootstrap\createPackageManager
‪static PackageManager createPackageManager($packageManagerClassName, FrontendInterface $coreCache)
Definition: Bootstrap.php:493
‪TYPO3\CMS\Core\Core\Bootstrap\initializeCachingFramework
‪Bootstrap initializeCachingFramework(bool $allowCaching=true)
Definition: Bootstrap.php:631
‪TYPO3\CMS\Core\Core\Bootstrap\setMemoryLimit
‪static setMemoryLimit()
Definition: Bootstrap.php:738
‪TYPO3\CMS\Core\Core\Bootstrap\checkIfEssentialConfigurationExists
‪static bool checkIfEssentialConfigurationExists(ConfigurationManager $configurationManager=null)
Definition: Bootstrap.php:388
‪TYPO3\CMS\Core\Core\Bootstrap\init
‪static ContainerInterface init(ClassLoader $classLoader, bool $failsafe=false)
Definition: Bootstrap.php:78
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendUser
‪static Bootstrap null initializeBackendUser($className=\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class)
Definition: Bootstrap.php:956
‪TYPO3\CMS\Core\Core\Bootstrap\__callStatic
‪static mixed __callStatic($methodName, array $arguments)
Definition: Bootstrap.php:1003
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Core\Core\Bootstrap\loadConfigurationAndInitialize
‪static Bootstrap null loadConfigurationAndInitialize( $allowCaching=true, $packageManagerClassName=\TYPO3\CMS\Core\Package\PackageManager::class, $isInternalCall=false)
Definition: Bootstrap.php:456
‪TYPO3\CMS\Core\Core\Bootstrap\setDefaultTimezone
‪static setDefaultTimezone()
Definition: Bootstrap.php:642
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:35
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:142
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:63
‪TYPO3\CMS\Core\Core\Bootstrap\initializeErrorHandling
‪static initializeErrorHandling()
Definition: Bootstrap.php:663
‪TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication
‪static Bootstrap null initializeBackendAuthentication($proceedIfNoUserIsLoggedIn=false)
Definition: Bootstrap.php:974
‪TYPO3\CMS\Core\Core\Bootstrap\disableCoreCache
‪static Bootstrap null disableCoreCache()
Definition: Bootstrap.php:599
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_CLI
‪const REQUESTTYPE_CLI
Definition: SystemEnvironmentBuilder.php:47
‪TYPO3\CMS\Core\Core\Bootstrap\createCacheManager
‪static CacheManager createCacheManager(bool $disableCaching=false)
Definition: Bootstrap.php:615
‪TYPO3\CMS\Core\Core\Bootstrap\configure
‪Bootstrap configure()
Definition: Bootstrap.php:302
‪TYPO3\CMS\Core\Core\Bootstrap\usesComposerClassLoading
‪static bool usesComposerClassLoading()
Definition: Bootstrap.php:237
‪$locales
‪$locales
Definition: be_users.php:6
‪TYPO3\CMS\Core\Core\Bootstrap\__construct
‪__construct()
Definition: Bootstrap.php:66
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:34
‪TYPO3\CMS\Core\Page\PageRenderer\setCache
‪static setCache(FrontendInterface $cache)
Definition: PageRenderer.php:377
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Core\Core\Bootstrap\loadTypo3LoadedExtAndExtLocalconf
‪static Bootstrap null loadTypo3LoadedExtAndExtLocalconf($allowCaching=true, FrontendInterface $coreCache=null)
Definition: Bootstrap.php:551
‪TYPO3\CMS\Core\Core\Bootstrap\setRequestType
‪Bootstrap setRequestType($requestType)
Definition: Bootstrap.php:775
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run
‪static run(int $entryPointLevel=0, int $requestType=self::REQUESTTYPE_FE)
Definition: SystemEnvironmentBuilder.php:81
‪TYPO3\CMS\Core\Core\Bootstrap\loadExtTables
‪static Bootstrap null loadExtTables(bool $allowCaching=true)
Definition: Bootstrap.php:864
‪TYPO3\CMS\Core\Core\Bootstrap\getEarlyInstance
‪object getEarlyInstance($objectName)
Definition: Bootstrap.php:423
‪TYPO3\CMS\Core\Core\Bootstrap\runExtTablesPostProcessingHooks
‪static runExtTablesPostProcessingHooks()
Definition: Bootstrap.php:876
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Core\Core\Bootstrap\initializePackageManagement
‪Bootstrap initializePackageManagement($packageManagerClassName)
Definition: Bootstrap.php:513
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:117
‪TYPO3\CMS\Core\Core\Bootstrap\$limbo
‪bool $limbo
Definition: Bootstrap.php:61
‪TYPO3\CMS\Core\Core\Bootstrap\startOutputBuffering
‪static Bootstrap null startOutputBuffering()
Definition: Bootstrap.php:287
‪TYPO3\CMS\Core\Core\Bootstrap\createApplicationContext
‪static ApplicationContext createApplicationContext()
Definition: Bootstrap.php:273
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:25
‪TYPO3\CMS\Core\Core
Definition: ApplicationContext.php:2
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Core\Core\ClassLoadingInformation\registerClassLoadingInformation
‪static registerClassLoadingInformation()
Definition: ClassLoadingInformation.php:107
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\loadExtTables
‪static loadExtTables($allowCaching=true)
Definition: ExtensionManagementUtility.php:1789
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\loadBaseTca
‪static loadBaseTca($allowCaching=true, FrontendInterface $codeCache=null)
Definition: ExtensionManagementUtility.php:1646
‪TYPO3\CMS\Core\Core\Bootstrap\createConfigurationManager
‪static ConfigurationManager createConfigurationManager()
Definition: Bootstrap.php:566
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\loadExtLocalconf
‪static loadExtLocalconf($allowCaching=true, FrontendInterface $codeCache=null)
Definition: ExtensionManagementUtility.php:1543
‪TYPO3\CMS\Core\Core\Bootstrap\populateLocalConfiguration
‪static Bootstrap populateLocalConfiguration(ConfigurationManager $configurationManager=null)
Definition: Bootstrap.php:579
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Core\Core\Bootstrap\__call
‪mixed __call($methodName, array $arguments)
Definition: Bootstrap.php:1024
‪TYPO3\CMS\Core\Imaging\IconRegistry\setCache
‪static setCache(FrontendInterface $cache)
Definition: IconRegistry.php:487
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:256
‪TYPO3\CMS\Core\Core\ClassLoadingInformation\setClassLoader
‪static setClassLoader(ClassLoader $classLoader)
Definition: ClassLoadingInformation.php:68
‪TYPO3\CMS\Core\Core\Bootstrap\setFinalCachingFrameworkCacheConfiguration
‪static Bootstrap null setFinalCachingFrameworkCacheConfiguration(CacheManager $cacheManager=null)
Definition: Bootstrap.php:792
‪TYPO3\CMS\Core\Core\Bootstrap\getEarlyInstances
‪array getEarlyInstances()
Definition: Bootstrap.php:438
‪TYPO3\CMS\Core\Core\Bootstrap\baseSetup
‪static Bootstrap baseSetup($entryPointLevel=null)
Definition: Bootstrap.php:325
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static Bootstrap null initializeLanguageObject()
Definition: Bootstrap.php:986