[FrameworkBundle] Make sure one can use fragments.hinclude_default_template

This commit is contained in:
Nyholm 2020-01-11 09:47:13 +01:00 committed by Fabien Potencier
parent 7e1a7b753e
commit 25fd665d0e
5 changed files with 31 additions and 1 deletions

View File

@ -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".');
}

View File

@ -0,0 +1,8 @@
<?php
$container->loadFromExtension('framework', [
'fragments' => [
'enabled' => true,
'hinclude_default_template' => 'global_hinclude_template',
],
]);

View File

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:fragments enabled="true" hinclude-default-template="global_hinclude_template"/>
</framework:config>
</container>

View File

@ -0,0 +1,4 @@
framework:
fragments:
enabled: true
hinclude_default_template: global_hinclude_template

View File

@ -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');