diff --git a/app/src/Middlewares.php b/app/src/Middlewares.php index 9501d25..721a2c9 100644 --- a/app/src/Middlewares.php +++ b/app/src/Middlewares.php @@ -16,6 +16,7 @@ use Twig\Error\LoaderError; class Middlewares { /** + * @param App $app The Slim application * @throws NotFoundExceptionInterface * @throws ContainerExceptionInterface * @throws LoaderError @@ -46,9 +47,10 @@ class Middlewares $twig->getEnvironment()->addGlobal('site_name', $config->get('site.name')); $twig->getEnvironment()->addGlobal('site_description', $config->get('site.description')); - $flash = $container->get(SessionInterface::class)->getFlash(); + $session = $container->get(SessionInterface::class); + $flash = $session->getFlash(); + $twig->getEnvironment()->addGlobal('session', $session); $twig->getEnvironment()->addGlobal('flash', $flash); - $twig->getEnvironment()->addGlobal('session', $container->get(SessionInterface::class)); $app->add(TwigMiddleware::create($app, $twig)); diff --git a/app/templates/layouts/components/flash.twig b/app/templates/layouts/components/flash.twig index fa1989d..d4497d6 100644 --- a/app/templates/layouts/components/flash.twig +++ b/app/templates/layouts/components/flash.twig @@ -10,10 +10,6 @@ {% endfor %} -{% if flash.has('error') %} -
Hello!
-{% endif %} - {% for message in flash.get('error') %}
{{ message }}