Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 01b2963

Browse filesBrowse files
[FrameworkBundle] decorate the ValidatorBuilder's translator with LegacyTranslatorProxy
1 parent dc2edaf commit 01b2963
Copy full SHA for 01b2963

File tree

2 files changed

+13
-1
lines changed
Filter options

2 files changed

+13
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
use Symfony\Component\Translation\Translator;
9898
use Symfony\Component\Validator\ConstraintValidatorInterface;
9999
use Symfony\Component\Validator\ObjectInitializerInterface;
100+
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
100101
use Symfony\Component\WebLink\HttpHeaderSerializer;
101102
use Symfony\Component\Workflow;
102103
use Symfony\Component\Workflow\WorkflowInterface;
@@ -1107,6 +1108,12 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
11071108

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

1111+
if (class_exists(LegacyTranslatorProxy::class)) {
1112+
$calls = $validatorBuilder->getMethodCalls();
1113+
$calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])]];
1114+
$validatorBuilder->setMethodCalls($calls);
1115+
}
1116+
11101117
$container->setParameter('validator.translation_domain', $config['translation_domain']);
11111118

11121119
$files = ['xml' => [], 'yml' => []];

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
use Symfony\Component\Serializer\Serializer;
5151
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
5252
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
53+
use Symfony\Component\Validator\Util\LegacyTranslatorProxy;
5354
use Symfony\Component\Workflow;
5455

5556
abstract class FrameworkExtensionTest extends TestCase
@@ -818,7 +819,11 @@ public function testValidation()
818819
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
819820
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
820821
$this->assertSame('setTranslator', $calls[1][0]);
821-
$this->assertEquals([new Reference('translator')], $calls[1][1]);
822+
if (class_exists(LegacyTranslatorProxy::class)) {
823+
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])], $calls[1][1]);
824+
} else {
825+
$this->assertEquals([new Reference('translator')], $calls[1][1]);
826+
}
822827
$this->assertSame('setTranslationDomain', $calls[2][0]);
823828
$this->assertSame(['%validator.translation_domain%'], $calls[2][1]);
824829
$this->assertSame('addXmlMappings', $calls[3][0]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.