‪TYPO3CMS  ‪main
RequestHandler.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 
18 namespace ‪TYPO3\CMS\Core\Http;
19 
20 use Psr\Container\ContainerInterface;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\ServerRequestInterface;
23 use Psr\Http\Server\RequestHandlerInterface;
24 use ‪TYPO3\CMS\Backend\Http\Application as BackendApplication;
26 use ‪TYPO3\CMS\Frontend\Http\Application as FrontendApplication;
27 
28 final class ‪RequestHandler implements RequestHandlerInterface
29 {
30  public function ‪__construct(
31  private readonly ContainerInterface $container,
32  private readonly ‪BackendEntryPointResolver $backendEntryPointResolver,
33  ) {}
34 
35  public function ‪handle(ServerRequestInterface $request): ResponseInterface
36  {
37  if ($this->container->has(BackendApplication::class) && $this->backendEntryPointResolver->isBackendRoute($request)) {
38  return $this->container->get(BackendApplication::class)->handle($request);
39  }
40 
41  if ($this->container->has(FrontendApplication::class)) {
42  return $this->container->get(FrontendApplication::class)->handle($request);
43  }
44 
45  throw new \Exception('TYPO3 is not configured. Please install typo3/cms-backend and/or typo3/cms-frontend', 1704788092);
46  }
47 }
‪TYPO3\CMS\Backend\Http\Application
Definition: Application.php:33
‪TYPO3\CMS\Core\Http\RequestHandler\handle
‪handle(ServerRequestInterface $request)
Definition: RequestHandler.php:35
‪TYPO3\CMS\Core\Http\RequestHandler
Definition: RequestHandler.php:29
‪TYPO3\CMS\Frontend\Http\Application
Definition: Application.php:35
‪TYPO3\CMS\Core\Routing\BackendEntryPointResolver
Definition: BackendEntryPointResolver.php:29
‪TYPO3\CMS\Core\Http\RequestHandler\__construct
‪__construct(private readonly ContainerInterface $container, private readonly BackendEntryPointResolver $backendEntryPointResolver,)
Definition: RequestHandler.php:30
‪TYPO3\CMS\Core\Http
Definition: AbstractApplication.php:18