diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 6909b15ae33d2..5f3173a0a469d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -547,7 +547,11 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB 'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader', )); - $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages')); + if ($container->has('assets.packages')) { + $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages')); + } else { + $container->removeDefinition('templating.helper.assets'); + } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php new file mode 100644 index 0000000000000..bf12a8bc47e5f --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php @@ -0,0 +1,7 @@ +loadFromExtension('framework', array( + 'templating' => array( + 'engines' => array('php', 'twig'), + ), +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php new file mode 100644 index 0000000000000..535a9a2e99c96 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php @@ -0,0 +1,8 @@ +loadFromExtension('framework', array( + 'assets' => false, + 'templating' => array( + 'engines' => array('php'), + ), +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml new file mode 100644 index 0000000000000..d579ed4c0a181 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml @@ -0,0 +1,14 @@ + + + + + + php + twig + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml new file mode 100644 index 0000000000000..393477aeb49ac --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml @@ -0,0 +1,3 @@ +framework: + templating: + engines: [php, twig] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml new file mode 100644 index 0000000000000..7ef6b3e57c292 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml @@ -0,0 +1,4 @@ +framework: + assets: false + templating: + engines: [php] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e655b52654d2c..a8aced55dd7fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -436,14 +436,21 @@ public function testAssetHelperWhenAssetsAreEnabled() $this->assertSame('assets.packages', (string) $packages); } - public function testAssetHelperWhenTemplatesAreEnabledAndAssetsAreDisabled() + public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration() { - $container = $this->createContainerFromFile('full'); + $container = $this->createContainerFromFile('templating_no_assets'); $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); $this->assertSame('assets.packages', (string) $packages); } + public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() + { + $container = $this->createContainerFromFile('templating_php_assets_disabled'); + + $this->assertTrue(!$container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.'); + } + public function testAssetHelperWhenAssetsAndTemplatesAreDisabled() { $container = $this->createContainerFromFile('default_config'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php index 2c27eb0325112..03401e2482942 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php @@ -22,4 +22,9 @@ protected function loadFromFile(ContainerBuilder $container, $file) $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')); $loader->load($file.'.xml'); } + + public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() + { + $this->markTestSkipped('The assets key cannot be set to false using the XML configuration format.'); + } }