From 56fb4094775cef141a151c1d4fd08e72dfa6116f Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 6 Sep 2018 17:22:08 +0200 Subject: [PATCH] Optimized flash messages --- application/src/Controller/SecurityController.php | 2 +- application/templates/frames/default.html.twig | 2 +- .../frames/structure/message/flash_messages.html.twig | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/application/src/Controller/SecurityController.php b/application/src/Controller/SecurityController.php index 2b562cf..b106448 100644 --- a/application/src/Controller/SecurityController.php +++ b/application/src/Controller/SecurityController.php @@ -21,7 +21,7 @@ class SecurityController extends AbstractController { $error = $authenticationUtils->getLastAuthenticationError(); if ($error) { - $this->addFlash('notice', $error); + $this->addFlash('danger', $error->getMessage()); } return $this->render("user/login.html.twig",[ 'last_username'=>$authenticationUtils->getLastUsername(), diff --git a/application/templates/frames/default.html.twig b/application/templates/frames/default.html.twig index 348c5cf..8833265 100644 --- a/application/templates/frames/default.html.twig +++ b/application/templates/frames/default.html.twig @@ -1,9 +1,9 @@ {% extends "base.html.twig" %} {% block body %} {% include 'frames/structure/navbar.html.twig'%} -{% include 'frames/structure/message/flash_messages.html.twig'%}
+ {% include 'frames/structure/message/flash_messages.html.twig'%} {% block content %} {% endblock %}
diff --git a/application/templates/frames/structure/message/flash_messages.html.twig b/application/templates/frames/structure/message/flash_messages.html.twig index 9a5368c..08f35fe 100644 --- a/application/templates/frames/structure/message/flash_messages.html.twig +++ b/application/templates/frames/structure/message/flash_messages.html.twig @@ -1,5 +1,8 @@ -{% for message in app.flashes('notice') %} -
- {{ message }} -
+{% set icons = {'success':'fas fa-check-circle','danger':'fas fa-times','warning':'fas fa-exclamation-triangle','info':'fas fa-info'} %} +{% for label,messages in app.flashes %} +{% for message in messages %} +
+ {{ message }} +
+{% endfor %} {% endfor %} \ No newline at end of file