/
var
/
www
/
html
/
stage
/
phpmyadmin
/
src
/
Http
/
Middleware
/
Upload File
HOME
<?php declare(strict_types=1); namespace PhpMyAdmin\Http\Middleware; use Fig\Http\Message\StatusCodeInterface; use PhpMyAdmin\Config; use PhpMyAdmin\Exceptions\ConfigException; use PhpMyAdmin\Http\Factory\ResponseFactory; use PhpMyAdmin\Template; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use const CONFIG_FILE; final class ConfigLoading implements MiddlewareInterface { public function __construct( private readonly Config $config, private readonly Template $template, private readonly ResponseFactory $responseFactory, ) { } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { try { $this->config->loadAndCheck(CONFIG_FILE); } catch (ConfigException $exception) { // Disables template caching because the cache directory is not known yet. $this->template->disableCache(); $response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR); return $response->write($this->template->render('error/generic', [ 'lang' => 'en', 'dir' => 'ltr', 'error_message' => $exception->getMessage(), ])); } return $handler->handle($request); } }