feature #30959 [FrameworkBundle] [TwigBundle] Move the hinclude key away from templating (Simperfit)
This PR was squashed before being merged into the 4.3-dev branch (closes #30959).
Discussion
----------
[FrameworkBundle] [TwigBundle] Move the hinclude key away from templating
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | yes <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #30874 <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | to do when pr is validated.
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
Maybe I shouldn't move directly the config key from templating to the other, but since the templating component has been deprecated we may change this directly without deprecating that key alone, WDYT ?
Commits
-------
4f39339fec
[FrameworkBundle] [TwigBundle] Move the hinclude key away from templating
This commit is contained in:
commit
35b1deda6b
@ -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()
|
||||
|
@ -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']);
|
||||
|
@ -69,6 +69,7 @@
|
||||
<xsd:complexType name="fragments">
|
||||
<xsd:attribute name="enabled" type="xsd:boolean" />
|
||||
<xsd:attribute name="path" type="xsd:string" />
|
||||
<xsd:attribute name="hinclude-default-template" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="web_link">
|
||||
|
@ -209,6 +209,7 @@ class ConfigurationTest extends TestCase
|
||||
'fragments' => [
|
||||
'enabled' => false,
|
||||
'path' => '/_fragment',
|
||||
'hinclude_default_template' => null,
|
||||
],
|
||||
'profiler' => [
|
||||
'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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testAmbiguousWhenBothTemplatingAndFragments()
|
||||
{
|
||||
$this->createContainerFromFile('template_and_fragments');
|
||||
}
|
||||
|
||||
public function testSsi()
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
|
Reference in New Issue
Block a user