-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Allow Validator without the translator component #28520
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
[Validator] Allow Validator without the translator component #28520
Conversation
99671a1
to
9e5ea39
Compare
|
||
foreach ($builder->getMethodCalls() as list($method, $arguments)) { | ||
if ('setTranslator' === $method) { | ||
$translator = $arguments[0] instanceof Reference ? $container->findDefinition($arguments[0]) : $arguments[0]; | ||
if ($arguments[0] instanceof Reference) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be enough to make sure that the reference is tagged with IGNORE_ON_INVALID_REFERENCE
(see https://symfony.com/doc/4.0/service_container/optional_dependencies.html#ignoring-missing-dependencies)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just setting the reference as "nullable" wouldn't work, we'd have the same error. Though, your put is interesting: I've made sure it ignores the reference only if it's "nullable".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no. I've just reverted 3e545e4 as it would break the ValidatorBuilderInterface
. AFAIK, that's the only way of dealing with it here.
3e545e4
to
9e5ea39
Compare
9e5ea39
to
c0d7091
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(using on-invalid="null"
wouldn't remove the need for doing this change as $translator is used below)
c0d7091
to
5c56d01
Compare
5c56d01
to
2dc92d7
Compare
FYI, it's a very important bug, it prevents the following to work:
|
Thank you @sroze. |
…nt (sroze) This PR was merged into the 4.2-dev branch. Discussion ---------- [Validator] Allow Validator without the translator component | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28210 | License | MIT | Doc PR | ø Validator should be available without the Translator service. #28210 introduced a regression, it was not the case anymore: ``` You have requested a non-existent service "translator". ``` This fixes it. Commits ------- 2dc92d7 Allow validator without the translator
Validator should be available without the Translator service. #28210 introduced a regression, it was not the case anymore:
This fixes it.