X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/blogbundle/blobdiff_plain/593afd90a9047fb444154b5544378386854bf87f..refs/heads/master:/Controller/DefaultController.php diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php index 65f02fe..dde6335 100644 --- a/Controller/DefaultController.php +++ b/Controller/DefaultController.php @@ -99,7 +99,7 @@ class DefaultController extends AbstractController { //Create the form according to the FormType created previously. //And give the proper parameters - $form = $this->createForm('Rapsys\BlogBundle\Form\ContactType', $data, [ + $form = $this->createForm('Rapsys\PackBundle\Form\ContactType', $data, [ 'action' => $this->generateUrl('rapsysblog_contact'), 'method' => 'POST' ]); @@ -140,8 +140,11 @@ class DefaultController extends AbstractController { //Send message $this->mailer->send($message); + //Add verification notice + $this->addFlash('notice', $this->translator->trans('Your message has been sent')); + //Redirect on the same route with sent=1 to cleanup form - return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params')); + return $this->redirectToRoute($request->attributes->get('_route'), $request->attributes->get('_route_params')); //Catch obvious transport exception } catch(TransportExceptionInterface $e) { //Add error message mail unreachable @@ -175,7 +178,7 @@ class DefaultController extends AbstractController { } //Render template - return $this->render('@RapsysBlog/form/contact.html.twig', ['contact' => $form->createView(), 'sent' => $request->query->get('sent', 0)]+$this->context, $response); + return $this->render('@RapsysBlog/form/contact.html.twig', ['contact' => $form->createView()]+$this->context, $response); } /** @@ -200,7 +203,7 @@ class DefaultController extends AbstractController { //Without keywords } else { //Set empty modified - $this->modified = new \DateTime('-1 year'); + $this->modified = new \DateTimeImmutable('-1 year'); } //Create response @@ -209,7 +212,7 @@ class DefaultController extends AbstractController { //With logged user if ($this->checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { //Set last modified - $response->setLastModified(new \DateTime('-1 year')); + $response->setLastModified(new \DateTimeImmutable('-1 year')); //Set as private $response->setPrivate();