‪TYPO3CMS  ‪main
EidHandler.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\MiddlewareInterface;
23 use Psr\Http\Server\RequestHandlerInterface;
26 
34 class ‪EidHandler implements MiddlewareInterface
35 {
36  public function ‪__construct(
37  protected readonly ‪DispatcherInterface $dispatcher
38  ) {}
39 
43  public function ‪process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
44  {
45  $eID = $request->getParsedBody()['eID'] ?? $request->getQueryParams()['eID'] ?? null;
46 
47  if ($eID === null) {
48  return $handler->handle($request);
49  }
50 
51  // Remove any output produced until now
52  ob_clean();
53 
54  if (!is_string($eID)) {
55  return (new ‪Response())->withStatus(400, 'Invalid eID');
56  }
57 
58  $target = ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID] ?? null;
59  if (empty($target)) {
60  return (new ‪Response())->withStatus(404, 'eID not registered');
61  }
62 
63  $request = $request->withAttribute('target', $target);
64  return $this->dispatcher->dispatch($request);
65  }
66 }
‪TYPO3\CMS\Frontend\Middleware\EidHandler
Definition: EidHandler.php:35
‪TYPO3\CMS\Frontend\Middleware\EidHandler\__construct
‪__construct(protected readonly DispatcherInterface $dispatcher)
Definition: EidHandler.php:36
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:32
‪TYPO3\CMS\Frontend\Middleware
Definition: BackendUserAuthenticator.php:18
‪TYPO3\CMS\Core\Http\DispatcherInterface
Definition: DispatcherInterface.php:30
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Frontend\Middleware\EidHandler\process
‪process(ServerRequestInterface $request, RequestHandlerInterface $handler)
Definition: EidHandler.php:43