diff --git a/app/src/Bootstrap.php b/app/src/Bootstrap.php index 0c6fe0e..ee0442c 100644 --- a/app/src/Bootstrap.php +++ b/app/src/Bootstrap.php @@ -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); + }); } /**