diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig
index f0ba10b..08efa74 100644
--- a/app/Resources/views/base.html.twig
+++ b/app/Resources/views/base.html.twig
@@ -78,6 +78,15 @@
+
+ {% for flash_message in app.session.flashBag.get('notice') %}
+
+
+
+ {{ flash_message }}
+
+ {% endfor %}
+
{% block body %}
{% endblock %}
diff --git a/src/AppBundle/Controller/ContactController.php b/src/AppBundle/Controller/ContactController.php
index 6862859..4d341c0 100644
--- a/src/AppBundle/Controller/ContactController.php
+++ b/src/AppBundle/Controller/ContactController.php
@@ -10,6 +10,7 @@
use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
use Symfony\Component\Routing\RouterInterface;
/**
@@ -26,16 +27,21 @@ class ContactController
/** @var RouterInterface */
private $router;
+ /** @var FlashBag */
+ private $flashBag;
+
/**
* @param FormFactory $formFactory
* @param MessageFacade $messageFacade
* @param RouterInterface $router
+ * @param FlashBag $flashBag
*/
- public function __construct(FormFactory $formFactory, MessageFacade $messageFacade, RouterInterface $router)
+ public function __construct(FormFactory $formFactory, MessageFacade $messageFacade, RouterInterface $router, FlashBag $flashBag)
{
$this->formFactory = $formFactory;
$this->messageFacade = $messageFacade;
$this->router = $router;
+ $this->flashBag = $flashBag;
}
/**
@@ -51,6 +57,8 @@ public function contactAction(Request $request)
if ($form->isSubmitted() && $form->isValid()) {
$this->messageFacade->save($messageVO);
+ $this->flashBag->add('notice', 'Message send.');
+
return RedirectResponse::create($this->router->generate("contact"));
}
diff --git a/src/AppBundle/Controller/FaqController.php b/src/AppBundle/Controller/FaqController.php
index 7614ee3..01e14c2 100644
--- a/src/AppBundle/Controller/FaqController.php
+++ b/src/AppBundle/Controller/FaqController.php
@@ -12,6 +12,7 @@
use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
use Symfony\Component\Routing\RouterInterface;
/**
@@ -34,20 +35,25 @@ class FaqController
/** @var RouterInterface */
private $router;
+ /** @var FlashBag */
+ private $flashBag;
+
/**
* @param FormFactory $formFactory
* @param QuestionFacade $questionFacade
* @param AnswerFacade $answerFacade
* @param FaqFacade $faqFacade
* @param RouterInterface $router
+ * @param FlashBag $flashBag
*/
- public function __construct(FormFactory $formFactory, QuestionFacade $questionFacade, AnswerFacade $answerFacade, FaqFacade $faqFacade, RouterInterface $router)
+ public function __construct(FormFactory $formFactory, QuestionFacade $questionFacade, AnswerFacade $answerFacade, FaqFacade $faqFacade, RouterInterface $router, FlashBag $flashBag)
{
$this->formFactory = $formFactory;
$this->questionFacade = $questionFacade;
$this->answerFacade = $answerFacade;
$this->faqFacade = $faqFacade;
$this->router = $router;
+ $this->flashBag = $flashBag;
}
/**
@@ -95,6 +101,8 @@ public function addAction(Request $request)
if ($form->isSubmitted() && $form->isValid()) {
$this->faqFacade->insert($faqVO);
+ $this->flashBag->add('notice', 'Question added.');
+
return RedirectResponse::create($this->router->generate("faq_list"));
}
@@ -122,6 +130,8 @@ public function editAction($id, Request $request)
if ($form->isSubmitted() && $form->isValid()) {
$this->faqFacade->update($question, $answer, $faqVO);
+ $this->flashBag->add('notice', 'Question uppdated.');
+
return RedirectResponse::create($this->router->generate("faq_list"));
}
@@ -129,4 +139,4 @@ public function editAction($id, Request $request)
"form" => $form->createView()
];
}
-}
\ No newline at end of file
+}