8000 bug #28520 [Validator] Allow Validator without the translator compone… · symfony/symfony@a1ca55b · GitHub
[go: up one dir, main page]

Skip to content

Commit a1ca55b

Browse files
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 ------- 2dc92d7 Allow validator without the translator
2 parents 05ebca7 + 2dc92d7 commit a1ca55b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,17 @@ public function process(ContainerBuilder $container)
4949

5050
// @deprecated logic, to be removed in Symfony 5.0
5151
$builder = $container->getDefinition($this->builderService);
52-
$calls = [];
52+
$calls = array();
5353

5454
foreach ($builder->getMethodCalls() as list($method, $arguments)) {
5555
if ('setTranslator' === $method) {
56-
$translator = $arguments[0] instanceof Reference ? $container->findDefinition($arguments[0]) : $arguments[0];
56+
if (!$arguments[0] instanceof Reference) {
57+
$translator = $arguments[0];
58+
} elseif ($container->has($arguments[0])) {
59+
$translator = $container->findDefinition($arguments[0]);
60+
} else {
61+
continue;
62+
}
5763

5864
while (!($class = $translator->getClass()) && $translator instanceof ChildDefinition) {
5965
$translator = $translator->getParent();

0 commit comments

Comments
 (0)
0