diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 15636fb1e6..00d0053dc4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -191,6 +191,7 @@ class Configuration implements ConfigurationInterface ->info('fragments configuration') ->canBeEnabled() ->children() + ->scalarNode('hinclude_default_template')->defaultNull()->end() ->scalarNode('path')->defaultValue('/_fragment')->end() ->end() ->end() @@ -610,7 +611,7 @@ class Configuration implements ConfigurationInterface ->then(function () { return ['enabled' => false, 'engines' => false]; }) ->end() ->children() - ->scalarNode('hinclude_default_template')->defaultNull()->end() + ->scalarNode('hinclude_default_template')->setDeprecated('Setting "templating.hinclude_default_template" is deprecated since Symfony 4.3, use "fragments.hinclude_default_template" instead.')->defaultNull()->end() ->scalarNode('cache')->end() ->arrayNode('form') ->addDefaultsIfNotSet() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 92aca42e31..338eddb949 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -487,6 +487,11 @@ class FrameworkExtension extends Extension return; } + if ($container->hasParameter('fragment.renderer.hinclude.global_template') && null !== $container->getParameter('fragment.renderer.hinclude.global_template') && null !== $config['hinclude_default_template']) { + throw new \LogicException('You cannot set both "templating.hinclude_default_template" and "fragments.hinclude_default_template", please only use "fragments.hinclude_default_template".'); + } + + $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']); $loader->load('fragment_listener.xml'); $container->setParameter('fragment.path', $config['path']); 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 9d71b403dd..478a505982 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 @@ -69,6 +69,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index c2455606b9..827988669f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -209,6 +209,7 @@ class ConfigurationTest extends TestCase 'fragments' => [ 'enabled' => false, 'path' => '/_fragment', + 'hinclude_default_template' => null, ], 'profiler' => [ 'enabled' => false, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php new file mode 100644 index 0000000000..6fd941d9f4 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php @@ -0,0 +1,18 @@ +loadFromExtension('framework', [ + 'templating' => [ + 'cache' => '/path/to/cache', + 'engines' => ['php', 'twig'], + 'loader' => ['loader.foo', 'loader.bar'], + 'form' => [ + 'resources' => ['theme1', 'theme2'], + ], + 'hinclude_default_template' => 'global_hinclude_template', + ], + 'assets' => null, + 'fragments' => [ + 'enabled' => true, + 'hinclude_default_template' => 'global_hinclude_template', + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml new file mode 100644 index 0000000000..d253e9f5de --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml @@ -0,0 +1,24 @@ + + + + + + + + + + loader.foo + loader.bar + php + twig + + theme1 + theme2 + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml new file mode 100644 index 0000000000..dbf7b69754 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml @@ -0,0 +1,12 @@ +framework: + fragments: + enabled: true + hinclude_default_template: global_hinclude_template + templating: + engines: [php, twig] + loader: [loader.foo, loader.bar] + cache: /path/to/cache + form: + resources: [theme1, theme2] + hinclude_default_template: global_hinclude_template + assets: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e3f727030c..8ebe5d9751 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -159,6 +159,14 @@ abstract class FrameworkExtensionTest extends TestCase $this->assertFalse($container->hasDefinition('esi')); } + /** + * @expectedException \LogicException + */ + public function testAmbiguousWhenBothTemplatingAndFragments() + { + $this->createContainerFromFile('template_and_fragments'); + } + public function testSsi() { $container = $this->createContainerFromFile('full');