Skip to content

Commit

Permalink
call method with Translator component only
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Apr 18, 2019
1 parent 87aef69 commit f49881d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -95,6 +95,7 @@
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;
Expand Down Expand Up @@ -1108,7 +1109,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder

$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);
Expand Down
Expand Up @@ -49,6 +49,7 @@
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;
Expand Down Expand Up @@ -819,7 +820,7 @@ public function testValidation()
$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]);
Expand Down

0 comments on commit f49881d

Please sign in to comment.