[TASK] Directly wire Application and RequestHandler
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Http / Application.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Backend\Http;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17 use TYPO3\CMS\Core\Core\Bootstrap;
18 use TYPO3\CMS\Core\Http\AbstractApplication;
19
20 /**
21 * Entry point for the TYPO3 Backend (HTTP requests)
22 */
23 class Application extends AbstractApplication
24 {
25 /**
26 * @var string
27 */
28 protected $requestHandler = RequestHandler::class;
29
30 /**
31 * @var string
32 */
33 protected $middlewareStack = 'backend';
34
35 /**
36 * @var Bootstrap
37 */
38 protected $bootstrap;
39
40 /**
41 * Number of subdirectories where the entry script is located, relative to PATH_site
42 * Usually this is equal to PATH_site = 0
43 * @var int
44 */
45 protected $entryPointLevel = 1;
46
47 /**
48 * Constructor setting up legacy constant and register available Request Handlers
49 *
50 * @param \Composer\Autoload\ClassLoader $classLoader an instance of the class loader
51 */
52 public function __construct($classLoader)
53 {
54 $this->defineLegacyConstants();
55
56 $this->bootstrap = Bootstrap::getInstance()
57 ->initializeClassLoader($classLoader)
58 ->setRequestType(TYPO3_REQUESTTYPE_BE | (isset($_REQUEST['route']) && strpos($_REQUEST['route'], '/ajax/') === 0 ? TYPO3_REQUESTTYPE_AJAX : 0))
59 ->baseSetup($this->entryPointLevel);
60
61 // Redirect to install tool if base configuration is not found
62 if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
63 $this->bootstrap->redirectToInstallTool($this->entryPointLevel);
64 }
65
66 $this->bootstrap->configure();
67 }
68
69 /**
70 * Define constants and variables
71 */
72 protected function defineLegacyConstants()
73 {
74 define('TYPO3_MODE', 'BE');
75 }
76 }