Add some documenation and pull the session interface out once.

This commit is contained in:
Dave Smith-Hayes 2024-11-25 20:45:16 -05:00
parent a1c3bea6e5
commit 7b12f10989
2 changed files with 4 additions and 6 deletions

View File

@ -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));

View File

@ -10,10 +10,6 @@
</div>
{% endfor %}
{% if flash.has('error') %}
<div>Hello!</div>
{% endif %}
{% for message in flash.get('error') %}
<div class="flash error">
{{ message }}