[TASK] Directly wire Application and RequestHandler
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Http / Application.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Frontend\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
18 use TYPO3\CMS\Core\Core\Bootstrap;
19 use TYPO3\CMS\Core\Http\AbstractApplication;
20
21 /**
22 * Entry point for the TYPO3 Frontend
23 */
24 class Application extends AbstractApplication
25 {
26 /**
27 * @var string
28 */
29 protected $requestHandler = RequestHandler::class;
30
31 /**
32 * @var string
33 */
34 protected $middlewareStack = 'frontend';
35
36 /**
37 * @var Bootstrap
38 */
39 protected $bootstrap;
40
41 /**
42 * Number of subdirectories where the entry script is located, relative to PATH_site
43 * Usually this is equal to PATH_site = 0
44 * @var int
45 */
46 protected $entryPointLevel = 0;
47
48 /**
49 * Constructor setting up legacy constant and register available Request Handlers
50 *
51 * @param \Composer\Autoload\ClassLoader $classLoader an instance of the class loader
52 */
53 public function __construct($classLoader)
54 {
55 $this->defineLegacyConstants();
56
57 $this->bootstrap = Bootstrap::getInstance()
58 ->initializeClassLoader($classLoader)
59 ->setRequestType(TYPO3_REQUESTTYPE_FE)
60 ->baseSetup($this->entryPointLevel);
61
62 // Redirect to install tool if base configuration is not found
63 if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
64 $this->bootstrap->redirectToInstallTool($this->entryPointLevel);
65 }
66
67 $this->bootstrap->configure();
68 }
69
70 /**
71 * Define constants and variables
72 */
73 protected function defineLegacyConstants()
74 {
75 define('TYPO3_MODE', 'FE');
76 }
77 }