[TASK] Update to latest class alias loader version
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Http / Application.php
1 <?php
2 namespace TYPO3\CMS\Install\Http;
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 use TYPO3\CMS\Core\Core\ApplicationInterface;
17 use TYPO3\CMS\Core\Core\Bootstrap;
18
19
20 /**
21 * Entry point for the TYPO3 Install Tool
22 */
23 class Application implements ApplicationInterface {
24
25 /**
26 * @var Bootstrap
27 */
28 protected $bootstrap;
29
30 /**
31 * @var string
32 */
33 protected $entryPointPath = 'typo3/sysext/install/Start/';
34
35 /**
36 * All available request handlers that can handle an install tool request
37 * @var array
38 */
39 protected $availableRequestHandlers = array(
40 \TYPO3\CMS\Install\Http\RequestHandler::class
41 );
42
43 /**
44 * Constructor setting up legacy constant and register available Request Handlers
45 *
46 * @param \Composer\Autoload\ClassLoader $classLoader an instance of the class loader
47 */
48 public function __construct($classLoader) {
49 $this->defineLegacyConstants();
50
51 $this->bootstrap = Bootstrap::getInstance()
52 ->initializeClassLoader($classLoader)
53 ->baseSetup($this->entryPointPath);
54
55 foreach ($this->availableRequestHandlers as $requestHandler) {
56 $this->bootstrap->registerRequestHandlerImplementation($requestHandler);
57 }
58
59 $this->bootstrap
60 ->startOutputBuffering()
61 ->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class);
62 }
63
64 /**
65 * Set up the application and shut it down afterwards
66 * Failsafe minimal setup mode for the install tool
67 * Does not call "run()" therefore
68 *
69 * @param callable $execute
70 * @return void
71 */
72 public function run(callable $execute = NULL) {
73 $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals());
74
75 if ($execute !== NULL) {
76 if ($execute instanceof \Closure) {
77 $execute->bindTo($this);
78 }
79 call_user_func($execute);
80 }
81
82 $this->bootstrap->shutdown();
83 }
84
85 /**
86 * Define constants
87 */
88 protected function defineLegacyConstants() {
89 define('TYPO3_MODE', 'BE');
90 define('TYPO3_enterInstallScript', '1');
91 }
92 }