diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 8a73424d9463f..6a8149993bc52 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -575,12 +575,17 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode) ->info('translator configuration') ->canBeEnabled() ->fixXmlConfig('fallback') + ->fixXmlConfig('path') ->children() ->arrayNode('fallbacks') ->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end() ->prototype('scalar')->end() ->defaultValue(array('en')) ->end() + ->arrayNode('paths') + ->defaultValue(array()) + ->prototype('scalar')->end() + ->end() ->booleanNode('logging')->defaultValue($this->debug)->end() ->end() ->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 2204c3ddeb4f1..773d9e34269be 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -661,6 +661,15 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder // Discover translation directories $dirs = array(); + + foreach ($config['paths'] as $path) { + if (!is_dir($path)) { + throw new \InvalidArgumentException(sprintf('The "%s" translation path does not exist.', $path)); + } + + $dirs[] = $path; + } + if (class_exists('Symfony\Component\Validator\Validation')) { $r = new \ReflectionClass('Symfony\Component\Validator\Validation'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index fa7aa2b2bd808..e1ca041e6114f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -183,6 +183,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 617be624fdb9f..f553d6387f26c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -146,6 +146,7 @@ protected static function getBundleDefaultConfig() 'enabled' => false, 'fallbacks' => array('en'), 'logging' => true, + 'paths' => array(), ), 'validation' => array( 'enabled' => false, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index a56bbff97a1dc..48a47c481a837 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -257,6 +257,17 @@ public function testTranslatorMultipleFallbacks() $this->assertEquals(array('en', 'fr'), $calls[0][1][0]); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" translation path does not exist. + */ + public function testTranslatorWithInvalidPaths() + { + $container = $this->createContainer(); + $loader = new FrameworkExtension(); + $loader->load(array(array('translator' => array('paths' => array('foo')))), $container); + } + /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */