From 394b8d890c39f61de7489bbd45c3be64ef5b6c4a Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 22 Mar 2026 10:51:22 +0200 Subject: [PATCH] move response logic to new view controller --- app/View/ViewController.php | 14 ++++++++++++++ bootstrap/app.php | 7 ++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 app/View/ViewController.php diff --git a/app/View/ViewController.php b/app/View/ViewController.php new file mode 100644 index 0000000..a41ac7e --- /dev/null +++ b/app/View/ViewController.php @@ -0,0 +1,14 @@ +render($response, 'admin.html.twig', []); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index ab6b076..5bbbb40 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -5,6 +5,7 @@ use Psr\Http\Message\ServerRequestInterface as Request; use DI\Bridge\Slim\Bridge; use Slim\Views\Twig; use Slim\Views\TwigMiddleware; +use App\View\ViewController; $container = require __DIR__.'/container.php'; $app = Bridge::create($container); @@ -14,10 +15,6 @@ $app->add(TwigMiddleware::create($app, $container->get(Twig::class))); // change first param to false for production $app->addErrorMiddleware(true, true, true); -$app->get('/admin', function (Response $response, Twig $twig) { - return $twig->render($response, 'admin.html.twig', [ - 'name' => 'John', - ]); -}); +$app->get('/admin', [ViewController::class, 'admin']); return $app;