[!!!][TASK] Remove deprecated Extbase Domain Models / Repositories / Converters
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Http / Application.php
1 <?php
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 namespace TYPO3\CMS\Install\Http;
17
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
20 use Psr\Http\Server\RequestHandlerInterface;
21 use TYPO3\CMS\Core\Context\Context;
22 use TYPO3\CMS\Core\Context\DateTimeAspect;
23 use TYPO3\CMS\Core\Context\UserAspect;
24 use TYPO3\CMS\Core\Context\VisibilityAspect;
25 use TYPO3\CMS\Core\Context\WorkspaceAspect;
26 use TYPO3\CMS\Core\Http\AbstractApplication;
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 * @var Context
36 */
37 protected $context;
38
39 public function __construct(
40 RequestHandlerInterface $requestHandler,
41 Context $context
42 ) {
43 $this->requestHandler = $requestHandler;
44 $this->context = $context;
45 }
46
47 protected function handle(ServerRequestInterface $request): ResponseInterface
48 {
49 $this->initializeContext();
50 return parent::handle($request)
51 ->withHeader('X-Frame-Options', 'SAMEORIGIN');
52 }
53
54 /**
55 * Initializes the Context used for accessing data and finding out the current state of the application
56 */
57 protected function initializeContext(): void
58 {
59 $this->context->setAspect('date', new DateTimeAspect(new \DateTimeImmutable('@' . $GLOBALS['EXEC_TIME'])));
60 $this->context->setAspect('visibility', new VisibilityAspect(true, true, true));
61 $this->context->setAspect('workspace', new WorkspaceAspect(0));
62 $this->context->setAspect('backend.user', new UserAspect());
63 }
64 }