getData();
$canWriteCache = self::canWriteCache();
// If skip cache is enabled, do not try to write it
// If no skip cache then try to write if write is possible
if (! $skipCache && $canWriteCache) {
$writeWorks = self::writeCache(
'dispatch($request->getMethod(), rawurldecode($route));
if ($routeInfo[0] === Dispatcher::NOT_FOUND) {
/** @var ResponseRenderer $response */
$response = $container->get(ResponseRenderer::class);
$response->setHttpResponseCode(404);
echo Message::error(sprintf(
__('Error 404! The page %s was not found.'),
'' . htmlspecialchars($route) . '
'
))->getDisplay();
return;
}
if ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
/** @var ResponseRenderer $response */
$response = $container->get(ResponseRenderer::class);
$response->setHttpResponseCode(405);
echo Message::error(__('Error 405! Request method not allowed.'))->getDisplay();
return;
}
if ($routeInfo[0] !== Dispatcher::FOUND) {
return;
}
/** @psalm-var class-string $controllerName */
$controllerName = $routeInfo[1];
/** @var array $vars */
$vars = $routeInfo[2];
/**
* @psalm-var callable(ServerRequest=, array=):void $controller
*/
$controller = $container->get($controllerName);
$controller($request, $vars);
}
}