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
|
class Middlewares
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* @param App $app The Slim application
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws LoaderError
|
* @throws LoaderError
|
||||||
@ -46,9 +47,10 @@ class Middlewares
|
|||||||
$twig->getEnvironment()->addGlobal('site_name', $config->get('site.name'));
|
$twig->getEnvironment()->addGlobal('site_name', $config->get('site.name'));
|
||||||
$twig->getEnvironment()->addGlobal('site_description', $config->get('site.description'));
|
$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('flash', $flash);
|
||||||
$twig->getEnvironment()->addGlobal('session', $container->get(SessionInterface::class));
|
|
||||||
|
|
||||||
$app->add(TwigMiddleware::create($app, $twig));
|
$app->add(TwigMiddleware::create($app, $twig));
|
||||||
|
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if flash.has('error') %}
|
|
||||||
<div>Hello!</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for message in flash.get('error') %}
|
{% for message in flash.get('error') %}
|
||||||
<div class="flash error">
|
<div class="flash error">
|
||||||
{{ message }}
|
{{ message }}
|
||||||
|
Loading…
Reference in New Issue
Block a user