‪TYPO3CMS  ‪main
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;
34 
39 {
40  public function ‪__construct(
41  RequestHandlerInterface ‪$requestHandler,
42  protected readonly ConfigurationManager $configurationManager,
43  protected readonly ‪Context $context,
44  protected readonly ‪BackendEntryPointResolver $backendEntryPointResolver
45  ) {
46  $this->requestHandler = ‪$requestHandler;
47  }
48 
49  public function ‪handle(ServerRequestInterface $request): ResponseInterface
50  {
51  if (!‪Bootstrap::checkIfEssentialConfigurationExists($this->configurationManager)) {
52  return $this->‪installToolRedirect($request);
53  }
54 
55  // Create new request object having applicationType "I am a frontend request" attribute.
56  $request = $request->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE);
57 
58  $this->‪initializeContext();
59  return parent::handle($request);
60  }
61 
65  protected function ‪installToolRedirect(ServerRequestInterface $request): ResponseInterface
66  {
67  return new ‪RedirectResponse($this->backendEntryPointResolver->getPathFromRequest($request) . 'install.php', 302);
68  }
69 
73  protected function ‪initializeContext(): void
74  {
75  $this->context->setAspect('date', new ‪DateTimeAspect(new \DateTimeImmutable('@' . ‪$GLOBALS['EXEC_TIME'])));
76  $this->context->setAspect('visibility', new ‪VisibilityAspect());
77  $this->context->setAspect('workspace', new ‪WorkspaceAspect(0));
78  $this->context->setAspect('backend.user', new ‪UserAspect(null));
79  $this->context->setAspect('frontend.user', new ‪UserAspect(null, [0, -1]));
80  }
81 }
‪TYPO3\CMS\Frontend\Http\Application\handle
‪handle(ServerRequestInterface $request)
Definition: Application.php:49
‪TYPO3\CMS\Core\Context\VisibilityAspect
Definition: VisibilityAspect.php:31
‪TYPO3\CMS\Core\Context\WorkspaceAspect
Definition: WorkspaceAspect.php:31
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Frontend\Http
Definition: Application.php:18
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:55
‪TYPO3\CMS\Core\Http\AbstractApplication
Definition: AbstractApplication.php:29
‪TYPO3\CMS\Frontend\Http\Application\installToolRedirect
‪installToolRedirect(ServerRequestInterface $request)
Definition: Application.php:65
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:28
‪TYPO3\CMS\Frontend\Http\Application\initializeContext
‪initializeContext()
Definition: Application.php:73
‪TYPO3\CMS\Frontend\Http\Application\__construct
‪__construct(RequestHandlerInterface $requestHandler, protected readonly ConfigurationManager $configurationManager, protected readonly Context $context, protected readonly BackendEntryPointResolver $backendEntryPointResolver)
Definition: Application.php:40
‪TYPO3\CMS\Core\Http\AbstractApplication\$requestHandler
‪RequestHandlerInterface null $requestHandler
Definition: AbstractApplication.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:61
‪TYPO3\CMS\Core\Core\Bootstrap\checkIfEssentialConfigurationExists
‪static bool checkIfEssentialConfigurationExists(ConfigurationManager $configurationManager)
Definition: Bootstrap.php:212
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Frontend\Http\Application
Definition: Application.php:39
‪TYPO3\CMS\Core\Routing\BackendEntryPointResolver
Definition: BackendEntryPointResolver.php:29
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:35
‪TYPO3\CMS\Core\Context\UserAspect
Definition: UserAspect.php:37