[FrameworkBundle] [TwigBundle] Move the hinclude key away from templating
This commit is contained in:
parent
35684187d5
commit
4f39339fec
@ -191,6 +191,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->info('fragments configuration')
|
->info('fragments configuration')
|
||||||
->canBeEnabled()
|
->canBeEnabled()
|
||||||
->children()
|
->children()
|
||||||
|
->scalarNode('hinclude_default_template')->defaultNull()->end()
|
||||||
->scalarNode('path')->defaultValue('/_fragment')->end()
|
->scalarNode('path')->defaultValue('/_fragment')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
@ -610,7 +611,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->then(function () { return ['enabled' => false, 'engines' => false]; })
|
->then(function () { return ['enabled' => false, 'engines' => false]; })
|
||||||
->end()
|
->end()
|
||||||
->children()
|
->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()
|
->scalarNode('cache')->end()
|
||||||
->arrayNode('form')
|
->arrayNode('form')
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
|
@ -487,6 +487,11 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
return;
|
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');
|
$loader->load('fragment_listener.xml');
|
||||||
$container->setParameter('fragment.path', $config['path']);
|
$container->setParameter('fragment.path', $config['path']);
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<xsd:complexType name="fragments">
|
<xsd:complexType name="fragments">
|
||||||
<xsd:attribute name="enabled" type="xsd:boolean" />
|
<xsd:attribute name="enabled" type="xsd:boolean" />
|
||||||
<xsd:attribute name="path" type="xsd:string" />
|
<xsd:attribute name="path" type="xsd:string" />
|
||||||
|
<xsd:attribute name="hinclude-default-template" type="xsd:string" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="web_link">
|
<xsd:complexType name="web_link">
|
||||||
|
@ -209,6 +209,7 @@ class ConfigurationTest extends TestCase
|
|||||||
'fragments' => [
|
'fragments' => [
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
'path' => '/_fragment',
|
'path' => '/_fragment',
|
||||||
|
'hinclude_default_template' => null,
|
||||||
],
|
],
|
||||||
'profiler' => [
|
'profiler' => [
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$container->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',
|
||||||
|
],
|
||||||
|
]);
|
@ -0,0 +1,24 @@
|
|||||||
|
<?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:esi enabled="true" />
|
||||||
|
<framework:ssi enabled="true" />
|
||||||
|
<framework:assets />
|
||||||
|
<framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template">
|
||||||
|
<framework:loader>loader.foo</framework:loader>
|
||||||
|
<framework:loader>loader.bar</framework:loader>
|
||||||
|
<framework:engine>php</framework:engine>
|
||||||
|
<framework:engine>twig</framework:engine>
|
||||||
|
<framework:form>
|
||||||
|
<framework:resource>theme1</framework:resource>
|
||||||
|
<framework:resource>theme2</framework:resource>
|
||||||
|
</framework:form>
|
||||||
|
</framework:templating>
|
||||||
|
</framework:config>
|
||||||
|
</container>
|
@ -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: ~
|
@ -159,6 +159,14 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertFalse($container->hasDefinition('esi'));
|
$this->assertFalse($container->hasDefinition('esi'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \LogicException
|
||||||
|
*/
|
||||||
|
public function testAmbiguousWhenBothTemplatingAndFragments()
|
||||||
|
{
|
||||||
|
$this->createContainerFromFile('template_and_fragments');
|
||||||
|
}
|
||||||
|
|
||||||
public function testSsi()
|
public function testSsi()
|
||||||
{
|
{
|
||||||
$container = $this->createContainerFromFile('full');
|
$container = $this->createContainerFromFile('full');
|
||||||
|
Reference in New Issue
Block a user