Skip to content

Commit

Permalink
bug #28520 [Validator] Allow Validator without the translator compone…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
nicolas-grekas committed Sep 20, 2018
2 parents 05ebca7 + 2dc92d7 commit a1ca55b
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -49,11 +49,17 @@ public function process(ContainerBuilder $container)

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

0 comments on commit a1ca55b

Please sign in to comment.