Add Flash messages, set the sessions to the storage during request.
This commit is contained in:
parent
7967f325fa
commit
d1ffe814cc
@ -55,7 +55,10 @@ class Bootstrap
|
||||
$containerBuilder->addDefinitions([
|
||||
'config' => $config,
|
||||
// more DI stuff
|
||||
|
||||
'flash' => function () {
|
||||
$messages = [];
|
||||
return new \Slim\Flash\Messages($messages);
|
||||
}
|
||||
]);
|
||||
|
||||
return $containerBuilder->build();
|
||||
@ -99,6 +102,16 @@ class Bootstrap
|
||||
->addGlobal('site_description', $config->get('site.description'));
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
|
||||
// Flash Messages
|
||||
$app->add(function ($req, $next) {
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$this->get('flash')->__construct($_SESSION);
|
||||
|
||||
return $next->handle($req);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user