call method with Translator component only

This commit is contained in:
Christian Flothmann 2019-04-18 08:02:03 +02:00
parent 87aef6984c
commit f49881d24a
2 changed files with 4 additions and 2 deletions

View File

@ -95,6 +95,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\ObjectInitializerInterface;
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
@ -1108,7 +1109,7 @@ class FrameworkExtension extends Extension
$validatorBuilder = $container->getDefinition('validator.builder');
if (class_exists(LegacyTranslatorProxy::class)) {
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
$calls = $validatorBuilder->getMethodCalls();
$calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])]];
$validatorBuilder->setMethodCalls($calls);

View File

@ -49,6 +49,7 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
use Symfony\Component\Workflow;
@ -819,7 +820,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
$this->assertSame('setTranslator', $calls[1][0]);
if (class_exists(LegacyTranslatorProxy::class)) {
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])], $calls[1][1]);
} else {
$this->assertEquals([new Reference('translator')], $calls[1][1]);