configurationManager = $configurationManager; } /** * @param ServerRequestInterface $request * @return ResponseInterface */ protected function handle(ServerRequestInterface $request): ResponseInterface { if (!$this->checkIfEssentialConfigurationExists()) { return $this->installToolRedirect(); } $this->initializeContext(); return parent::handle($request); } /** * Check if LocalConfiguration.php and PackageStates.php exist * * @return bool TRUE when the essential configuration is available, otherwise FALSE */ protected function checkIfEssentialConfigurationExists(): bool { return file_exists($this->configurationManager->getLocalConfigurationFileLocation()) && file_exists(Environment::getLegacyConfigPath() . '/PackageStates.php'); } /** * Create a PSR-7 Response that redirects to the install tool * * @return ResponseInterface */ protected function installToolRedirect(): ResponseInterface { $path = TYPO3_mainDir . 'install.php'; return new RedirectResponse($path, 302); } /** * Initializes the Context used for accessing data and finding out the current state of the application * Will be moved to a DI-like concept once introduced, for now, this is a singleton */ protected function initializeContext() { GeneralUtility::makeInstance(Context::class, [ 'date' => new DateTimeAspect(new \DateTimeImmutable('@' . $GLOBALS['EXEC_TIME'])), 'visibility' => new VisibilityAspect(), 'workspace' => new WorkspaceAspect(0), 'backend.user' => new UserAspect(null), 'frontend.user' => new UserAspect(null, [0, -1]), ]); } }