‪TYPO3CMS  9.5
EidRequestHandler.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
20 use Psr\Http\Server\RequestHandlerInterface as PsrRequestHandlerInterface;
28 
35 class ‪EidRequestHandler implements ‪RequestHandlerInterface, PsrRequestHandlerInterface
36 {
40  public function ‪__construct()
41  {
42  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
43  }
44 
51  public function ‪handleRequest(ServerRequestInterface $request): ResponseInterface
52  {
53  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
54  return $this->‪handle($request);
55  }
56 
63  public function ‪canHandleRequest(ServerRequestInterface $request): bool
64  {
65  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
66  return !empty($request->getQueryParams()['eID']) || !empty($request->getParsedBody()['eID']);
67  }
68 
75  public function ‪getPriority(): int
76  {
77  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
78  return 80;
79  }
80 
88  public function ‪handle(ServerRequestInterface $request): ResponseInterface
89  {
90  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware::class . ' instead.', E_USER_DEPRECATED);
91  // Remove any output produced until now
92  ob_clean();
93 
95  $response = GeneralUtility::makeInstance(Response::class);
96 
97  $eID = $request->getParsedBody()['eID'] ?? $request->getQueryParams()['eID'] ?? '';
98 
99  if (empty($eID) || !isset(‪$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID])) {
100  return $response->withStatus(404, 'eID not registered');
101  }
102 
103  $configuration = ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID];
104 
105  // Simple check to make sure that it's not an absolute file (to use the fallback)
106  if (strpos($configuration, '::') !== false || is_callable($configuration)) {
108  $dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
109  $request = $request->withAttribute('target', $configuration);
110  return $dispatcher->dispatch($request, $response);
111  }
112 
113  $scriptPath = GeneralUtility::getFileAbsFileName($configuration);
114  if ($scriptPath === '') {
115  throw new ‪Exception('Registered eID has invalid script path.', 1416391467);
116  }
117  include $scriptPath;
118  return new ‪NullResponse();
119  }
120 }
‪TYPO3\CMS\Core\Http\Dispatcher
Definition: Dispatcher.php:29
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Frontend\Http
Definition: Application.php:3
‪TYPO3\CMS\Frontend\Middleware\EidHandler
Definition: EidHandler.php:36
‪TYPO3\CMS\Frontend\Http\EidRequestHandler\__construct
‪__construct()
Definition: EidRequestHandler.php:40
‪TYPO3\CMS\Core\Exception
‪TYPO3\CMS\Core\Http\NullResponse
Definition: NullResponse.php:24
‪TYPO3\CMS\Core\Http\RequestHandlerInterface
Definition: RequestHandlerInterface.php:28
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:28
‪TYPO3\CMS\Frontend\Http\EidRequestHandler\getPriority
‪int getPriority()
Definition: EidRequestHandler.php:75
‪TYPO3\CMS\Frontend\Http\EidRequestHandler\handle
‪ResponseInterface handle(ServerRequestInterface $request)
Definition: EidRequestHandler.php:88
‪TYPO3\CMS\Frontend\Http\EidRequestHandler\handleRequest
‪ResponseInterface handleRequest(ServerRequestInterface $request)
Definition: EidRequestHandler.php:51
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\Http\EidRequestHandler\canHandleRequest
‪bool canHandleRequest(ServerRequestInterface $request)
Definition: EidRequestHandler.php:63
‪TYPO3\CMS\Frontend\Http\EidRequestHandler
Definition: EidRequestHandler.php:36
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45