From 2f7a8f1ebc177aa25c00a8726be60b00e018d56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 20 Aug 2018 21:34:53 +0200 Subject: [PATCH] add more generic message when invalid form during person update --- Controller/PersonController.php | 18 ++++++++++++++---- Resources/config/services/controller.yml | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Controller/PersonController.php b/Controller/PersonController.php index 08a57e0b4..abec3629f 100644 --- a/Controller/PersonController.php +++ b/Controller/PersonController.php @@ -31,6 +31,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Role\Role; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Search\SimilarPersonMatcher; +use Symfony\Component\Translation\TranslatorInterface; class PersonController extends Controller { @@ -39,10 +40,19 @@ class PersonController extends Controller * @var SimilarPersonMatcher */ protected $similarPersonMatcher; + + /** + * + * @var TranslatorInterface + */ + protected $translator; - public function __construct(SimilarPersonMatcher $similarPersonMatcher) - { + public function __construct( + SimilarPersonMatcher $similarPersonMatcher, + TranslatorInterface $translator + ) { $this->similarPersonMatcher = $similarPersonMatcher; + $this->translator = $translator; } public function getCFGroup() @@ -119,8 +129,8 @@ class PersonController extends Controller if ( ! $form->isValid() ) { $this->get('session') - ->getFlashBag()->add('error', 'The person data provided' - . ' are not valid'); + ->getFlashBag()->add('error', $this->translator + ->trans('This form contains errors')); return $this->render('ChillPersonBundle:Person:edit.html.twig', array('person' => $person, diff --git a/Resources/config/services/controller.yml b/Resources/config/services/controller.yml index 174edbf0a..d47ab2cbd 100644 --- a/Resources/config/services/controller.yml +++ b/Resources/config/services/controller.yml @@ -2,4 +2,5 @@ services: Chill\PersonBundle\Controller\PersonController: arguments: $similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher' + $translator: '@Symfony\Component\Translation\TranslatorInterface' tags: ['controller.service_arguments']