Skip to content

Pass validator.translation_domain to RequestPayloadValueResolver #58187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: pass validator.translation_domain to RequestPayloadValueResolver
  • Loading branch information
raphael-geffroy authored and nicolas-grekas committed Sep 10, 2024
commit 2d45107368b689feba5c5c9260e63544cb5c50b0
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
) {
}

Expand Down Expand Up @@ -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();
Expand Down
Loading
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