‪TYPO3CMS  10.4
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;
33 
38 {
42  protected ‪$configurationManager;
43 
47  protected ‪$context;
48 
49  public function ‪__construct(
50  RequestHandlerInterface ‪$requestHandler,
51  ConfigurationManager ‪$configurationManager,
53  ) {
54  $this->requestHandler = ‪$requestHandler;
55  $this->configurationManager = ‪$configurationManager;
56  $this->context = ‪$context;
57  }
58 
59  protected function ‪handle(ServerRequestInterface $request): ResponseInterface
60  {
62  return $this->‪installToolRedirect();
63  }
64 
65  // Create new request object having applicationType "I am a frontend request" attribute.
66  $request = $request->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE);
67 
68  $this->‪initializeContext();
69  return parent::handle($request);
70  }
71 
77  protected function ‪checkIfEssentialConfigurationExists(): bool
78  {
79  return file_exists($this->configurationManager->getLocalConfigurationFileLocation())
80  && file_exists(‪Environment::getLegacyConfigPath() . '/PackageStates.php');
81  }
82 
88  protected function ‪installToolRedirect(): ResponseInterface
89  {
90  $path = TYPO3_mainDir . 'install.php';
91  return new RedirectResponse($path, 302);
92  }
93 
97  protected function ‪initializeContext(): void
98  {
99  $this->context->setAspect('date', new DateTimeAspect(new \DateTimeImmutable('@' . ‪$GLOBALS['EXEC_TIME'])));
100  $this->context->setAspect('visibility', new VisibilityAspect());
101  $this->context->setAspect('workspace', new WorkspaceAspect(0));
102  $this->context->setAspect('backend.user', new UserAspect(null));
103  $this->context->setAspect('frontend.user', new UserAspect(null, [0, -1]));
104  }
105 }
‪TYPO3\CMS\Frontend\Http\Application\handle
‪handle(ServerRequestInterface $request)
Definition: Application.php:57
‪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:42
‪TYPO3\CMS\Frontend\Http
Definition: Application.php:18
‪TYPO3\CMS\Frontend\Http\Application\installToolRedirect
‪ResponseInterface installToolRedirect()
Definition: Application.php:86
‪TYPO3\CMS\Frontend\Http\Application\$context
‪Context $context
Definition: Application.php:45
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Core\Http\AbstractApplication
Definition: AbstractApplication.php:29
‪TYPO3\CMS\Frontend\Http\Application\checkIfEssentialConfigurationExists
‪bool checkIfEssentialConfigurationExists()
Definition: Application.php:75
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:28
‪TYPO3\CMS\Frontend\Http\Application\initializeContext
‪initializeContext()
Definition: Application.php:95
‪TYPO3\CMS\Frontend\Http\Application\__construct
‪__construct(RequestHandlerInterface $requestHandler, ConfigurationManager $configurationManager, Context $context)
Definition: Application.php:47
‪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:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Frontend\Http\Application\$configurationManager
‪ConfigurationManager $configurationManager
Definition: Application.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:44
‪TYPO3\CMS\Frontend\Http\Application
Definition: Application.php:38
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:35
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:282
‪TYPO3\CMS\Core\Context\UserAspect
Definition: UserAspect.php:38