2 declare(strict_types = 1);
18 use Doctrine\DBAL\Exception\ConnectionException;
19 use Psr\Http\Message\ResponseInterface;
20 use Psr\Http\Message\ServerRequestInterface;
21 use Psr\Http\Server\MiddlewareInterface;
22 use Psr\Http\Server\RequestHandlerInterface;
23 use Psr\Log\LoggerAwareInterface;
24 use Psr\Log\LoggerAwareTrait;
52 public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
54 $GLOBALS[
'TSFE'] = GeneralUtility::makeInstance(
55 TypoScriptFrontendController::class,
57 GeneralUtility::_GP(
'id'),
58 GeneralUtility::_GP(
'type'),
60 GeneralUtility::_GP(
'cHash'),
62 GeneralUtility::_GP(
'MP')
64 if (GeneralUtility::_GP(
'no_cache')) {
65 $GLOBALS[
'TSFE']->set_no_cache(
'&no_cache=1 has been supplied, so caching is disabled! URL: "' . (
string)$request->getUri() .
'"');
70 $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(
'pages');
71 $connection->connect();
72 }
catch (ConnectionException | \RuntimeException $exception) {
73 $message =
'Cannot connect to the configured database';
74 $this->logger->emergency($message, [
'exception' => $exception]);
76 return GeneralUtility::makeInstance(ErrorController::class)->unavailableAction($request, $message);
82 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_fe.php'][
'connectToDB'])) {
83 trigger_error(
'The "connectToDB" hook will be removed in TYPO3 v10.0 in favor of PSR-15. Use a middleware instead.', E_USER_DEPRECATED);
84 $_params = [
'pObj' => &
$GLOBALS[
'TSFE']];
85 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_fe.php'][
'connectToDB'] as $_funcRef) {
86 GeneralUtility::callUserFunction($_funcRef, $_params,
$GLOBALS[
'TSFE']);
90 return $handler->handle($request);