‪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;
30 
35 {
36  public function ‪__construct(
37  RequestHandlerInterface ‪$requestHandler,
38  protected readonly ‪Context $context,
39  ) {
40  $this->requestHandler = ‪$requestHandler;
41  }
42 
43  public function ‪handle(ServerRequestInterface $request): ResponseInterface
44  {
45  // Create new request object having applicationType "I am a frontend request" attribute.
46  $request = $request->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE);
47 
48  $this->‪initializeContext();
49  return parent::handle($request);
50  }
51 
55  protected function ‪initializeContext(): void
56  {
57  $this->context->setAspect(
58  'date',
60  (new \DateTimeImmutable())->setTimestamp(‪$GLOBALS['EXEC_TIME'])
61  )
62  );
63  $this->context->setAspect('visibility', new ‪VisibilityAspect());
64  $this->context->setAspect('workspace', new ‪WorkspaceAspect(0));
65  $this->context->setAspect('backend.user', new ‪UserAspect(null));
66  $this->context->setAspect('frontend.user', new ‪UserAspect(null, [0, -1]));
67  }
68 }
‪TYPO3\CMS\Frontend\Http\Application\handle
‪handle(ServerRequestInterface $request)
Definition: Application.php:43
‪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:54
‪TYPO3\CMS\Frontend\Http\Application\__construct
‪__construct(RequestHandlerInterface $requestHandler, protected readonly Context $context,)
Definition: Application.php:36
‪TYPO3\CMS\Core\Http\AbstractApplication
Definition: AbstractApplication.php:29
‪TYPO3\CMS\Frontend\Http\Application\initializeContext
‪initializeContext()
Definition: Application.php:55
‪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\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Frontend\Http\Application
Definition: Application.php:35
‪TYPO3\CMS\Core\Context\DateTimeAspect
Definition: DateTimeAspect.php:35
‪TYPO3\CMS\Core\Context\UserAspect
Definition: UserAspect.php:37