‪TYPO3CMS  10.4
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;
28 
36 class ‪EidHandler implements MiddlewareInterface
37 {
41  protected ‪$dispatcher;
42 
47  {
48  $this->dispatcher = ‪$dispatcher;
49  }
50 
59  public function ‪process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
60  {
61  $eID = $request->getParsedBody()['eID'] ?? $request->getQueryParams()['eID'] ?? null;
62 
63  if ($eID === null) {
64  return $handler->handle($request);
65  }
66 
67  // Remove any output produced until now
68  ob_clean();
69 
70  if (!is_string($eID)) {
71  return (new ‪Response())->withStatus(400, 'Invalid eID');
72  }
73 
74  $target = ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID] ?? null;
75  if (empty($target)) {
76  return (new ‪Response())->withStatus(404, 'eID not registered');
77  }
78 
79  $request = $request->withAttribute('target', $target);
80  return $this->dispatcher->dispatch($request) ?? new ‪NullResponse();
81  }
82 }
‪TYPO3\CMS\Frontend\Middleware\EidHandler\$dispatcher
‪DispatcherInterface $dispatcher
Definition: EidHandler.php:40
‪TYPO3\CMS\Frontend\Middleware\EidHandler
Definition: EidHandler.php:37
‪TYPO3\CMS\Core\Exception
‪TYPO3\CMS\Core\Http\NullResponse
Definition: NullResponse.php:26
‪TYPO3\CMS\Frontend\Middleware\EidHandler\__construct
‪__construct(DispatcherInterface $dispatcher)
Definition: EidHandler.php:45
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:30
‪TYPO3\CMS\Frontend\Middleware
Definition: BackendUserAuthenticator.php:18
‪TYPO3\CMS\Frontend\Middleware\EidHandler\process
‪ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)
Definition: EidHandler.php:58
‪TYPO3\CMS\Core\Http\DispatcherInterface
Definition: DispatcherInterface.php:30
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5