[FEATURE] Add symfony dependency injection for core and extbase
[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
17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use Psr\Http\Server\RequestHandlerInterface;
20 use TYPO3\CMS\Core\Context\Context;
21 use TYPO3\CMS\Core\Context\DateTimeAspect;
22 use TYPO3\CMS\Core\Context\UserAspect;
23 use TYPO3\CMS\Core\Context\VisibilityAspect;
24 use TYPO3\CMS\Core\Context\WorkspaceAspect;
25 use TYPO3\CMS\Core\Http\AbstractApplication;
26 use TYPO3\CMS\Core\Utility\GeneralUtility;
27
28 /**
29 * Entry point for the TYPO3 Install Tool
30 * @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.
31 */
32 class Application extends AbstractApplication
33 {
34 /**
35 * @param RequestHandlerInterface $requestHandler
36 */
37 public function __construct(RequestHandlerInterface $requestHandler)
38 {
39 $this->requestHandler = $requestHandler;
40 }
41
42 /**
43 * @param ServerRequestInterface $request
44 * @return ResponseInterface
45 */
46 protected function handle(ServerRequestInterface $request): ResponseInterface
47 {
48 $this->initializeContext();
49 return parent::handle($request);
50 }
51
52 /**
53 * Initializes the Context used for accessing data and finding out the current state of the application
54 * Will be moved to a DI-like concept once introduced, for now, this is a singleton
55 */
56 protected function initializeContext()
57 {
58 GeneralUtility::makeInstance(Context::class, [
59 'date' => new DateTimeAspect(new \DateTimeImmutable('@' . $GLOBALS['EXEC_TIME'])),
60 'visibility' => new VisibilityAspect(true, true, true),
61 'workspace' => new WorkspaceAspect(0),
62 'backend.user' => new UserAspect(),
63 ]);
64 }
65 }