handle($request); } /** * Handles any AJAX request in the TYPO3 Backend, after finishing running middlewares * * Creates a response object with JSON headers automatically, and then dispatches to the correct route * * @param ServerRequestInterface $request * @return ResponseInterface * @throws ResourceNotFoundException if no valid route was found * @throws InvalidRequestTokenException if the request could not be verified */ public function handle(ServerRequestInterface $request): ResponseInterface { trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED); /** @var Response $response */ $response = GeneralUtility::makeInstance(Response::class, 'php://temp', 200, [ 'Content-Type' => 'application/json; charset=utf-8', 'X-JSON' => 'true' ]); /** @var RouteDispatcher $dispatcher */ $dispatcher = GeneralUtility::makeInstance(RouteDispatcher::class); return $dispatcher->dispatch($request, $response); } /** * This request handler can handle any backend request having * an /ajax/ request * * @param ServerRequestInterface $request * @return bool If the request is an AJAX backend request, TRUE otherwise FALSE */ public function canHandleRequest(ServerRequestInterface $request): bool { trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED); $routePath = $request->getParsedBody()['route'] ?? $request->getQueryParams()['route'] ?? ''; return strpos($routePath, '/ajax/') === 0; } /** * Returns the priority - how eager the handler is to actually handle the request. * * @return int The priority of the request handler. */ public function getPriority(): int { trigger_error(self::class . ' will be removed in TYPO3 v10.0. Use the regular application dispatcher instead.', E_USER_DEPRECATED); return 80; } }