8000 bug #31156 [FrameworkBundle] call method with Translator component on… · symfony/symfony@cc497a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit cc497a5

Browse files
bug #31156 [FrameworkBundle] call method with Translator component only (xabbuh)
This PR was merged into the 4.2 branch. Discussion ---------- [FrameworkBundle] call method with Translator component only | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31152 | License | MIT | Doc PR | Commits ------- f49881d call method with Translator component only
2 parents 87aef69 + f49881d commit cc497a5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
use Symfony\Component\Stopwatch\Stopwatch;
9696
use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
9797
use Symfony\Component\Translation\Translator;
98+
use Symfony\Component\Translation\TranslatorInterface;
9899
use Symfony\Component\Validator\ConstraintValidatorInterface;
99100
use Symfony\Component\Validator\ObjectInitializerInterface;
100101
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
@@ -1108,7 +1109,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
11081109

11091110
$validatorBuilder = $container->getDefinition('validator.builder');
11101111

1111-
if (class_exists(LegacyTranslatorProxy::class)) {
1112+
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
11121113
$calls = $validatorBuilder->getMethodCalls();
11131114
$calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])]];
11141115
$validatorBuilder->setMethodCalls($calls);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
5050
use Symfony\Component\Serializer\Serializer;
5151
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
52+
use Symfony\Component\Translation\TranslatorInterface;
5253
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
5354
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
5455
use Symfony\Component\Workflow;
@@ -819,7 +820,7 @@ public function testValidation()
819820
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
820821
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
821822
$this->assertSame('setTranslator', $calls[1][0]);
822-
if (class_exists(LegacyTranslatorProxy::class)) {
823+
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
823824
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])], $calls[1][1]);
824825
} else {
825826
$this->assertEquals([new Reference('translator')], $calls[1][1]);

0 commit comments

Comments
 (0)
0