Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkBundle] [TwigBundle] Move the hinclude key away from templating #30959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] [TwigBundle] Move the hinclude key away from templa…
…ting
  • Loading branch information
Amrouche Hamza authored and fabpot committed Apr 8, 2019
commit 4f39339fec120ecc5078d287e0e9b80be1a9765a
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private function addFragmentsSection(ArrayNodeDefinition $rootNode)
->info('fragments configuration')
->canBeEnabled()
->children()
->scalarNode('hinclude_default_template')->defaultNull()->end()
->scalarNode('path')->defaultValue('/_fragment')->end()
->end()
->end()
Expand Down Expand Up @@ -610,7 +611,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->then(function () { return ['enabled' => false, 'engines' => false]; })
->end()
->children()
->scalarNode('hinclude_default_template')->defaultNull()->end()
Simperfit marked this conversation as resolved.
Show resolved Hide resolved
->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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ private function registerFragmentsConfiguration(array $config, ContainerBuilder

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']);
Simperfit marked this conversation as resolved.
Show resolved Hide resolved

$loader->load('fragment_listener.xml');
$container->setParameter('fragment.path', $config['path']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ protected static function getBundleDefaultConfig()
'fragments' => [
'enabled' => false,
'path' => '/_fragment',
'hinclude_default_template' => null,
],
'profiler' => [
'enabled' => false,
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
],
]);
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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: ~
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ public function testEsiDisabled()
$this->assertFalse($container->hasDefinition('esi'));
}

/**
* @expectedException \LogicException
*/
public function testAmbiguousWhenBothTemplatingAndFragments()
{
$this->createContainerFromFile('template_and_fragments');
}

public function testSsi()
{
$container = $this->createContainerFromFile('full');
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.