From 25fd665d0e77a8709222e7585005c2fdf44fe153 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 11 Jan 2020 09:47:13 +0100 Subject: [PATCH] [FrameworkBundle] Make sure one can use fragments.hinclude_default_template --- .../DependencyInjection/FrameworkExtension.php | 2 +- .../Fixtures/php/fragments_and_hinclude.php | 8 ++++++++ .../Fixtures/xml/fragments_and_hinclude.xml | 11 +++++++++++ .../Fixtures/yml/fragments_and_hinclude.yml | 4 ++++ .../DependencyInjection/FrameworkExtensionTest.php | 7 +++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index a6b8f4658d..b3a7095cce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -523,7 +523,7 @@ 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']) { + if ($container->hasParameter('fragment.renderer.hinclude.global_template') && '' !== $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".'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php new file mode 100644 index 0000000000..dbcf5b786d --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/fragments_and_hinclude.php @@ -0,0 +1,8 @@ +loadFromExtension('framework', [ + 'fragments' => [ + 'enabled' => true, + 'hinclude_default_template' => 'global_hinclude_template', + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml new file mode 100644 index 0000000000..fb007313b9 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/fragments_and_hinclude.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml new file mode 100644 index 0000000000..b03f37da79 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/fragments_and_hinclude.yml @@ -0,0 +1,4 @@ +framework: + fragments: + enabled: true + hinclude_default_template: global_hinclude_template diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 8366faf918..99d9fc6ece 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -170,6 +170,13 @@ abstract class FrameworkExtensionTest extends TestCase $this->createContainerFromFile('template_and_fragments'); } + public function testFragmentsAndHinclude() + { + $container = $this->createContainerFromFile('fragments_and_hinclude'); + $this->assertTrue($container->hasParameter('fragment.renderer.hinclude.global_template')); + $this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template')); + } + public function testSsi() { $container = $this->createContainerFromFile('full');