‪TYPO3CMS  11.5
Application.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
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 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use Psr\Http\Server\RequestHandlerInterface;
23 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
31 
36 {
40  protected ‪$configurationManager;
41 
45  protected ‪$context;
46 
47  public function ‪__construct(
48  RequestHandlerInterface ‪$requestHandler,
49  ConfigurationManager ‪$configurationManager,
51  ) {
52  $this->requestHandler = ‪$requestHandler;
53  $this->configurationManager = ‪$configurationManager;
54  $this->context = ‪$context;
55  }
56 
57  public function ‪handle(ServerRequestInterface $request): ResponseInterface
58  {
59  if (!‪Bootstrap::checkIfEssentialConfigurationExists($this->configurationManager)) {
60  return $this->‪installToolRedirect();
61  }
62 
63  // Add applicationType attribute to request: This is backend and maybe backend ajax.
65  if (str_contains($request->getUri()->getPath(), '/typo3/ajax/') || strpos($request->getQueryParams()['route'] ?? '', '/ajax/') === 0) {
67  }
68  $request = $request->withAttribute('applicationType', $applicationType);
69 
70  // Set up the initial context
71  $this->‪initializeContext();
72  return parent::handle($request);
73  }
74 
80  protected function ‪installToolRedirect(): ResponseInterface
81  {
82  return new RedirectResponse('./install.php', 302);
83  }
84 
88  protected function ‪initializeContext(): void
89  {
90  $this->context->setAspect(
91  'date',
92  new DateTimeAspect(
93  (new \DateTimeImmutable())->setTimestamp(‪$GLOBALS['EXEC_TIME'])
94  )
95  );
96  $this->context->setAspect('visibility', new VisibilityAspect(true, true));
97  }
98 }
‪TYPO3\CMS\Backend\Http\Application\handle
‪handle(ServerRequestInterface $request)
Definition: Application.php:55
‪TYPO3\CMS\Core\Context\VisibilityAspect
Definition: VisibilityAspect.php:31
‪TYPO3\CMS\Backend\Http\Application
Definition: Application.php:36
‪TYPO3\CMS\Backend\Http
Definition: Application.php:18
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Core\Http\AbstractApplication
Definition: AbstractApplication.php:29
‪TYPO3\CMS\Backend\Http\Application\__construct
‪__construct(RequestHandlerInterface $requestHandler, ConfigurationManager $configurationManager, Context $context)
Definition: Application.php:45
‪TYPO3\CMS\Backend\Http\Application\installToolRedirect
‪ResponseInterface installToolRedirect()
Definition: Application.php:78
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:28
‪TYPO3\CMS\Backend\Http\Application\$configurationManager
‪ConfigurationManager $configurationManager
Definition: Application.php:39
‪TYPO3\CMS\Core\Http\AbstractApplication\$requestHandler
‪RequestHandlerInterface null $requestHandler
Definition: AbstractApplication.php:36
‪TYPO3\CMS\Backend\Http\Application\initializeContext
‪initializeContext()
Definition: Application.php:86
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_AJAX
‪const REQUESTTYPE_AJAX
Definition: SystemEnvironmentBuilder.php:49
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:70
‪TYPO3\CMS\Core\Core\Bootstrap\checkIfEssentialConfigurationExists
‪static bool checkIfEssentialConfigurationExists(ConfigurationManager $configurationManager)
Definition: Bootstrap.php:234
‪TYPO3\CMS\Backend\Http\Application\$context
‪Context $context
Definition: Application.php:43
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:35