bug #28520 [Validator] Allow Validator without the translator component (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
-------
2dc92d7a4b
Allow validator without the translator
This commit is contained in:
commit
a1ca55beea
@ -49,11 +49,17 @@ class AddValidatorInitializersPass implements CompilerPassInterface
|
||||
|
||||
// @deprecated logic, to be removed in Symfony 5.0
|
||||
$builder = $container->getDefinition($this->builderService);
|
||||
$calls = [];
|
||||
$calls = array();
|
||||
|
||||
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) {
|
||||
$translator = $arguments[0];
|
||||
} elseif ($container->has($arguments[0])) {
|
||||
$translator = $container->findDefinition($arguments[0]);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!($class = $translator->getClass()) && $translator instanceof ChildDefinition) {
|
||||
$translator = $translator->getParent();
|
||||
|
Reference in New Issue
Block a user