2 declare(strict_types
= 1);
3 namespace TYPO3\CMS\Frontend\Http
;
6 * This file is part of the TYPO3 CMS project.
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.
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
15 * The TYPO3 project - inspiring people to share!
18 use Psr\Http\Message\ResponseInterface
;
19 use Psr\Http\Message\ServerRequestInterface
;
20 use Psr\Http\Server\RequestHandlerInterface
as PsrRequestHandlerInterface
;
21 use TYPO3\CMS\Core\Exception
;
22 use TYPO3\CMS\Core\Http\Dispatcher
;
23 use TYPO3\CMS\Core\Http\NullResponse
;
24 use TYPO3\CMS\Core\Http\RequestHandlerInterface
;
25 use TYPO3\CMS\Core\Http\Response
;
26 use TYPO3\CMS\Core\Utility\GeneralUtility
;
27 use TYPO3\CMS\Frontend\Middleware\EidHandler
as EidMiddleware
;
30 * Lightweight alternative to the regular RequestHandler used when $_GET[eID] is set.
31 * In the future, logic from the EidUtility will be moved to this class.
33 * @deprecated since TYPO3 v9.2, will be removed in TYPO3 v10.0
35 class EidRequestHandler
implements RequestHandlerInterface
, PsrRequestHandlerInterface
38 * Constructor handing over the bootstrap and the original request
40 public function __construct()
42 trigger_error(self
::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware
::class . ' instead.', E_USER_DEPRECATED
);
46 * Handles a frontend request based on the _GP "eID" variable.
48 * @param ServerRequestInterface $request
49 * @return ResponseInterface
51 public function handleRequest(ServerRequestInterface
$request): ResponseInterface
53 trigger_error(self
::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware
::class . ' instead.', E_USER_DEPRECATED
);
54 return $this->handle($request);
58 * This request handler can handle any frontend request.
60 * @param ServerRequestInterface $request The request to process
61 * @return bool If the request is not an eID request, TRUE otherwise FALSE
63 public function canHandleRequest(ServerRequestInterface
$request): bool
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']);
70 * Returns the priority - how eager the handler is to actually handle the
73 * @return int The priority of the request handler.
75 public function getPriority(): int
77 trigger_error(self
::class . ' will be removed in TYPO3 v10.0. Use ' . EidMiddleware
::class . ' instead.', E_USER_DEPRECATED
);
82 * Dispatches the request to the corresponding eID class or eID script
84 * @param ServerRequestInterface $request
85 * @return ResponseInterface
88 public function handle(ServerRequestInterface
$request): ResponseInterface
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
94 $eID = $request->getParsedBody()['eID'] ??
$request->getQueryParams()['eID'] ??
'';
96 if (empty($eID) ||
!isset($GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID])) {
97 return (new Response())->withStatus(404, 'eID not registered');
100 $configuration = $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID];
102 // Simple check to make sure that it's not an absolute file (to use the fallback)
103 if (strpos($configuration, '::') !== false ||
is_callable($configuration)) {
104 $dispatcher = GeneralUtility
::makeInstance(Dispatcher
::class);
105 $request = $request->withAttribute('target', $configuration);
106 return $dispatcher->dispatch($request);
109 $scriptPath = GeneralUtility
::getFileAbsFileName($configuration);
110 if ($scriptPath === '') {
111 throw new Exception('Registered eID has invalid script path.', 1416391467);
114 return new NullResponse();