‪TYPO3CMS  9.5
AjaxRequestHandler.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;
26 
36 class ‪AjaxRequestHandler implements ‪RequestHandlerInterface, PsrRequestHandlerInterface
37 {
44  public function ‪handleRequest(ServerRequestInterface $request): ResponseInterface
45  {
46  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED);
47  return $this->‪handle($request);
48  }
49 
60  public function ‪handle(ServerRequestInterface $request): ResponseInterface
61  {
62  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED);
64  $response = GeneralUtility::makeInstance(Response::class, 'php://temp', 200, [
65  'Content-Type' => 'application/json; charset=utf-8',
66  'X-JSON' => 'true'
67  ]);
68 
70  $dispatcher = GeneralUtility::makeInstance(RouteDispatcher::class);
71  return $dispatcher->dispatch($request, $response);
72  }
73 
81  public function ‪canHandleRequest(ServerRequestInterface $request): bool
82  {
83  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED);
84  $routePath = $request->getParsedBody()['route'] ?? $request->getQueryParams()['route'] ?? '';
85  return strpos($routePath, '/ajax/') === 0;
86  }
87 
93  public function ‪getPriority(): int
94  {
95  trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED);
96  return 80;
97  }
98 }
‪TYPO3\CMS\Backend\Routing\Exception\InvalidRequestTokenException
Definition: InvalidRequestTokenException.php:21
‪TYPO3\CMS\Backend\Http
Definition: AjaxRequestHandler.php:3
‪TYPO3\CMS\Backend\Http\AjaxRequestHandler\handleRequest
‪ResponseInterface handleRequest(ServerRequestInterface $request)
Definition: AjaxRequestHandler.php:44
‪TYPO3\CMS\Backend\Http\AjaxRequestHandler\canHandleRequest
‪bool canHandleRequest(ServerRequestInterface $request)
Definition: AjaxRequestHandler.php:81
‪TYPO3\CMS\Backend\Http\AjaxRequestHandler\handle
‪ResponseInterface handle(ServerRequestInterface $request)
Definition: AjaxRequestHandler.php:60
‪TYPO3\CMS\Core\Http\RequestHandlerInterface
Definition: RequestHandlerInterface.php:28
‪TYPO3\CMS\Core\Http\Response
Definition: Response.php:28
‪TYPO3\CMS\Backend\Http\AjaxRequestHandler\getPriority
‪int getPriority()
Definition: AjaxRequestHandler.php:93
‪TYPO3\CMS\Backend\Routing\Exception\ResourceNotFoundException
Definition: ResourceNotFoundException.php:21
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Http\AjaxRequestHandler
Definition: AjaxRequestHandler.php:37