From 2d45107368b689feba5c5c9260e63544cb5c50b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Geffroy?= <81738559+raphael-geffroy@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:43:15 +0200 Subject: [PATCH] fix: pass validator.translation_domain to RequestPayloadValueResolver --- src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php | 1 + .../ArgumentResolver/RequestPayloadValueResolver.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php index 6710dabdab3e5..6f8358fb0c7b8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php @@ -71,6 +71,7 @@ service('serializer'), service('validator')->nullOnInvalid(), service('translator')->nullOnInvalid(), + param('validator.translation_domain'), ]) ->tag('controller.targeted_value_resolver', ['name' => RequestPayloadValueResolver::class]) ->tag('kernel.event_subscriber') diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php index 94d04bfe4ec28..1f0ff7cc0f053 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php @@ -65,6 +65,7 @@ public function __construct( private readonly SerializerInterface&DenormalizerInterface $serializer, private readonly ?ValidatorInterface $validator = null, private readonly ?TranslatorInterface $translator = null, + private string $translationDomain = 'validators', ) { } @@ -137,7 +138,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo if ($error->canUseMessageForUser()) { $parameters['hint'] = $error->getMessage(); } - $message = $trans($template, $parameters, 'validators'); + $message = $trans($template, $parameters, $this->translationDomain); $violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null)); } $payload = $e->getData(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy