Use Twig-only rendering and improve error fallback
Remove legacy PHP view fallbacks and always render Twig templates (Controller, Router). Update ErrorHandler to attempt Twig rendering and provide a safe, escaped minimal HTML fallback on failure instead of requiring PHP views. Also pass whoisData into the domain view. These changes standardize on Twig templates and harden error output.
This commit is contained in:
@@ -6,23 +6,8 @@ abstract class Controller
|
||||
{
|
||||
protected function view(string $view, array $data = []): void
|
||||
{
|
||||
$twigPath = __DIR__ . "/../app/Views/$view.twig";
|
||||
|
||||
if (file_exists($twigPath)) {
|
||||
$twig = TwigService::getInstance();
|
||||
echo $twig->render("$view.twig", $data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback to legacy PHP view during migration
|
||||
extract($data);
|
||||
$viewPath = __DIR__ . "/../app/Views/$view.php";
|
||||
|
||||
if (!file_exists($viewPath)) {
|
||||
throw new \Exception("View not found: $view");
|
||||
}
|
||||
|
||||
require $viewPath;
|
||||
$twig = TwigService::getInstance();
|
||||
echo $twig->render("$view.twig", $data);
|
||||
}
|
||||
|
||||
protected function json($data, int $status = 200): void
|
||||
|
||||
@@ -72,12 +72,7 @@ class Router
|
||||
// Silently fail if logging is not available
|
||||
}
|
||||
|
||||
$twigPath = __DIR__ . '/../app/Views/errors/404.twig';
|
||||
if (file_exists($twigPath)) {
|
||||
echo TwigService::getInstance()->render('errors/404.twig');
|
||||
} else {
|
||||
require_once __DIR__ . '/../app/Views/errors/404.php';
|
||||
}
|
||||
echo TwigService::getInstance()->render('errors/404.twig');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user