2 declare(strict_types = 1);
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\Configuration\ConfigurationManager;
43 public function handleRequest(ServerRequestInterface $request): ResponseInterface
45 return $this->
handle($request);
55 public function handle(ServerRequestInterface $request): ResponseInterface
58 $actionName = $request->getParsedBody()[
'install'][
'action'] ?? $request->getQueryParams()[
'install'][
'action'] ??
'init';
59 $action = $actionName .
'Action';
61 if ($actionName ===
'init' || $actionName ===
'mainLayout') {
62 $response = $controller->$action();
63 } elseif ($actionName ===
'checkInstallerAvailable') {
67 } elseif ($actionName ===
'showInstallerNotAvailable') {
68 $response = $controller->showInstallerNotAvailableAction();
69 } elseif ($actionName ===
'checkEnvironmentAndFolders'
70 || $actionName ===
'showEnvironmentAndFolders'
71 || $actionName ===
'executeEnvironmentAndFolders'
74 $response = $controller->$action($request);
79 if (!$session->hasSession()) {
80 $session->startSession();
82 if ($session->isExpired()) {
83 $session->refreshSession();
85 $postValues = $request->getParsedBody()[
'install'];
86 $sessionTokenOk =
false;
87 if (empty($postValues)) {
89 $sessionTokenOk =
true;
91 if (isset($postValues[
'token'])) {
94 if ($actionName ===
'') {
95 throw new \RuntimeException(
'No POST action given for token check', 1505647681);
97 $sessionTokenOk = $formProtection->validateToken($postValues[
'token'],
'installTool', $actionName);
99 if (!$sessionTokenOk) {
100 $session->resetSession();
101 $session->startSession();
102 throw new \RuntimeException(
'Invalid session token', 1505647737);
105 if (!method_exists($controller, $action)) {
107 throw new \RuntimeException(
108 'Unknown action method ' . $action .
' in controller InstallerController',
113 $response = $controller->$action($request);
115 if ($actionName ===
'executeDefaultConfiguration') {
117 $session->destroySession();
133 $localConfigurationFileLocation = (
new ConfigurationManager())->getLocalConfigurationFileLocation();
153 throw new \RuntimeException(
154 'Installer not available',