Skip to content

Commit 2d45107

Browse files
raphael-geffroynicolas-grekas
authored andcommitted
fix: pass validator.translation_domain to RequestPayloadValueResolver
1 parent fdf4094 commit 2d45107

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
service('serializer'),
7272
service('validator')->nullOnInvalid(),
7373
service('translator')->nullOnInvalid(),
74+
param('validator.translation_domain'),
7475
])
7576
->tag('controller.targeted_value_resolver', ['name' => RequestPayloadValueResolver::class])
7677
->tag('kernel.event_subscriber')

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/RequestPayloadValueResolver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function __construct(
6565
private readonly SerializerInterface&DenormalizerInterface $serializer,
6666
private readonly ?ValidatorInterface $validator = null,
6767
private readonly ?TranslatorInterface $translator = null,
68+
private string $translationDomain = 'validators',
6869
) {
6970
}
7071

@@ -137,7 +138,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo
137138
if ($error->canUseMessageForUser()) {
138139
$parameters['hint'] = $error->getMessage();
139140
}
140-
$message = $trans($template, $parameters, 'validators');
141+
$message = $trans($template, $parameters, $this->translationDomain);
141142
$violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null));
142143
}
143144
$payload = $e->getData();

0 commit comments

Comments
 (0)