Add some documenation and pull the session interface out once.
This commit is contained in:
parent
a1c3bea6e5
commit
7b12f10989
@ -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));
|
||||
|
||||
|
@ -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 }}
|
||||
|
Loading…
Reference in New Issue
Block a user