configurationManager = $configurationManager; } /** * @param ServerRequestInterface $request * @return ResponseInterface */ protected function handle(ServerRequestInterface $request): ResponseInterface { if (!$this->checkIfEssentialConfigurationExists()) { return $this->installToolRedirect(); } // Set up the initial context $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 { return new RedirectResponse('./install.php', 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(true, true) ]); } }