2 namespace TYPO3\CMS\Backend\Http
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
16 use TYPO3\CMS\Core\Core\ApplicationInterface
;
17 use TYPO3\CMS\Core\Core\Bootstrap
;
20 * Entry point for the TYPO3 Backend (HTTP requests)
22 class Application
implements ApplicationInterface
30 * Number of subdirectories where the entry script is located, relative to PATH_site
31 * Usually this is equal to PATH_site = 0
34 protected $entryPointLevel = 1;
37 * @var \Psr\Http\Message\ServerRequestInterface
42 * All available request handlers that can handle backend requests (non-CLI)
45 protected $availableRequestHandlers = [
46 \TYPO3\CMS\Backend\Http\RequestHandler
::class,
47 \TYPO3\CMS\Backend\Http\BackendModuleRequestHandler
::class,
48 \TYPO3\CMS\Backend\Http\AjaxRequestHandler
::class
52 * Constructor setting up legacy constant and register available Request Handlers
54 * @param \Composer\Autoload\ClassLoader $classLoader an instance of the class loader
56 public function __construct($classLoader)
58 $this->defineLegacyConstants();
60 $this->bootstrap
= Bootstrap
::getInstance()
61 ->initializeClassLoader($classLoader)
62 ->setRequestType(TYPO3_REQUESTTYPE_BE |
(isset($_REQUEST['route']) && strpos($_REQUEST['route'], '/ajax/') === 0 ? TYPO3_REQUESTTYPE_AJAX
: 0))
63 ->baseSetup($this->entryPointLevel
);
65 // Redirect to install tool if base configuration is not found
66 if (!$this->bootstrap
->checkIfEssentialConfigurationExists()) {
67 $this->bootstrap
->redirectToInstallTool($this->entryPointLevel
);
70 foreach ($this->availableRequestHandlers
as $requestHandler) {
71 $this->bootstrap
->registerRequestHandlerImplementation($requestHandler);
74 $this->bootstrap
->configure();
78 * Set up the application and shut it down afterwards
80 * @param callable $execute
82 public function run(callable
$execute = null)
84 $this->request
= \TYPO3\CMS\Core\Http\ServerRequestFactory
::fromGlobals();
85 if (isset($this->request
->getQueryParams()['M'])) {
86 $this->request
= $this->request
->withAttribute('isModuleRequest', true);
89 $this->bootstrap
->handleRequest($this->request
);
91 if ($execute !== null) {
92 call_user_func($execute);
95 $this->bootstrap
->shutdown();
99 * Define constants and variables
101 protected function defineLegacyConstants()
103 define('TYPO3_MODE', 'BE');