[!!!][TASK] Drop "documentation" extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Http / Application.php
1 <?php
2 namespace TYPO3\CMS\Install\Http;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Core\Http\AbstractApplication;
20 use TYPO3\CMS\Core\Http\RequestHandlerInterface;
21
22 /**
23 * Entry point for the TYPO3 Install Tool
24 */
25 class Application extends AbstractApplication
26 {
27 /**
28 * All available request handlers that can handle an install tool request
29 * @var array
30 */
31 protected $availableRequestHandlers = [];
32
33 /**
34 * Construct Application
35 *
36 * @param RequestHandlerInterface $requestHandler
37 * @param RequestHandlerInterface $installerRequestHandler
38 */
39 public function __construct(
40 RequestHandlerInterface $requestHandler,
41 RequestHandlerInterface $installerRequestHandler
42 ) {
43 $this->availableRequestHandlers = [
44 $requestHandler,
45 $installerRequestHandler
46 ];
47 }
48
49 /**
50 * @param ServerRequestInterface $request
51 * @return ResponseInterface
52 */
53 protected function handle(ServerRequestInterface $request): ResponseInterface
54 {
55 foreach ($this->availableRequestHandlers as $handler) {
56 if ($handler->canHandleRequest($request)) {
57 return $handler->handleRequest($request);
58 }
59 }
60
61 throw new \TYPO3\CMS\Core\Exception('No suitable request handler found.', 1518448686);
62 }
63 }