Skip to content

Commit 19eb90d

Browse files
committed
Ignore missing translation dependency in FrameworkBundle
When using symfony/framework-bundle with symfony/validator installed but without symfony/translation, the call to setTranslator will error out because of the missing translator service. Thus, the call to setTranslator needs to ignore a missing translator dependency to support this scenario.
1 parent 376a8f4 commit 19eb90d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<argument type="service" id="validator.validator_factory" />
2424
</call>
2525
<call method="setTranslator">
26-
<argument type="service" id="translator" />
26+
<argument type="service" id="translator" on-invalid="ignore" />
2727
</call>
2828
<call method="setTranslationDomain">
2929
<argument>%validator.translation_domain%</argument>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ public function testValidation()
674674
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
675675
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
676676
$this->assertSame('setTranslator', $calls[1][0]);
677-
$this->assertEquals([new Reference('translator')], $calls[1][1]);
677+
$this->assertEquals([new Reference('translator', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)], $calls[1][1]);
678678
$this->assertSame('setTranslationDomain', $calls[2][0]);
679679
$this->assertSame(['%validator.translation_domain%'], $calls[2][1]);
680680
$this->assertSame('addXmlMappings', $calls[3][0]);

0 commit comments

Comments
 (0)