Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
99671a1 to9e5ea39Compare| foreach ($builder->getMethodCalls()aslist($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 withIGNORE_ON_INVALID_REFERENCE (seehttps://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 referenceonly 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 reverted3e545e4 as it would break theValidatorBuilderInterface. AFAIK, that's the only way of dealing with it here.
3e545e4 to9e5ea39Compare9e5ea39 toc0d7091Compare
nicolas-grekas left a comment
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.
(usingon-invalid="null" wouldn't remove the need for doing this change as $translator is used below)
c0d7091 to5c56d01Compare5c56d01 to2dc92d7Comparesroze commentedSep 20, 2018
FYI, it's a very important bug, it prevents the following to work: |
nicolas-grekas commentedSep 20, 2018
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.