Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit400ed9a

Browse files
author
Amrouche Hamza
committed
add test and add exception when using both
1 parent0a0d913 commit400ed9a

File tree

6 files changed

+68
-6
lines changed

6 files changed

+68
-6
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,12 @@ private function registerFragmentsConfiguration(array $config, ContainerBuilder
487487

488488
return;
489489
}
490-
491-
if (!$container->hasParameter('fragment.renderer.hinclude.global_template')) {
492-
$container->setParameter('fragment.renderer.hinclude.global_template',$config['hinclude_default_template']);
490+
if ($container->hasParameter('fragment.renderer.hinclude.global_template') && (null !==$container->getParameter('fragment.renderer.hinclude.global_template') &&null !==$config['hinclude_default_template'])) {
491+
thrownew \LogicException('Ambiguous configuration detected, prior to Symfony 4.3 you should not use both config keys ("templating.hinclude_default_template" and "fragments.hinclude_default_template", please use "fragments.hinclude_default_template".');
493492
}
494493

494+
$container->setParameter('fragment.renderer.hinclude.global_template',$config['hinclude_default_template']);
495+
495496
$loader->load('fragment_listener.xml');
496497
$container->setParameter('fragment.path',$config['path']);
497498
}
@@ -909,9 +910,7 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder
909910
{
910911
$loader->load('templating.xml');
911912

912-
if (!$container->hasParameter('fragment.renderer.hinclude.global_template')) {
913-
$container->setParameter('fragment.renderer.hinclude.global_template',$config['hinclude_default_template']);
914-
}
913+
$container->setParameter('fragment.renderer.hinclude.global_template',$config['hinclude_default_template']);
915914

916915
if ($container->getParameter('kernel.debug')) {
917916
$logger =newReference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE);

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<xsd:complexTypename="fragments">
7070
<xsd:attributename="enabled"type="xsd:boolean" />
7171
<xsd:attributename="path"type="xsd:string" />
72+
<xsd:attributename="hinclude-default-template"type="xsd:string" />
7273
</xsd:complexType>
7374

7475
<xsd:complexTypename="web_link">
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'templating' => [
5+
'cache' =>'/path/to/cache',
6+
'engines' => ['php','twig'],
7+
'loader' => ['loader.foo','loader.bar'],
8+
'form' => [
9+
'resources' => ['theme1','theme2'],
10+
],
11+
'hinclude_default_template' =>'global_hinclude_template',
12+
],
13+
'assets' =>null,
14+
'fragments' => [
15+
'enabled' =>true,
16+
'hinclude_default_template' =>'global_hinclude_template',
17+
],
18+
]);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" ?>
2+
<containerxmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:fragmentsenabled="true"hinclude-default-template="global_hinclude_template"/>
10+
<framework:esienabled="true" />
11+
<framework:ssienabled="true" />
12+
<framework:assets />
13+
<framework:templatingcache="/path/to/cache"hinclude-default-template="global_hinclude_template">
14+
<framework:loader>loader.foo</framework:loader>
15+
<framework:loader>loader.bar</framework:loader>
16+
<framework:engine>php</framework:engine>
17+
<framework:engine>twig</framework:engine>
18+
<framework:form>
19+
<framework:resource>theme1</framework:resource>
20+
<framework:resource>theme2</framework:resource>
21+
</framework:form>
22+
</framework:templating>
23+
</framework:config>
24+
</container>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
framework:
2+
fragments:
3+
enabled:true
4+
hinclude_default_template:global_hinclude_template
5+
templating:
6+
engines:[php, twig]
7+
loader:[loader.foo, loader.bar]
8+
cache:/path/to/cache
9+
form:
10+
resources:[theme1, theme2]
11+
hinclude_default_template:global_hinclude_template
12+
assets:~

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ public function testEsiDisabled()
159159
$this->assertFalse($container->hasDefinition('esi'));
160160
}
161161

162+
/**
163+
* @expectedException \LogicException
164+
*/
165+
publicfunctiontestAmbiguousWhenBothTemplatingAndFragments()
166+
{
167+
$this->createContainerFromFile('template_and_fragments');
168+
}
169+
162170
publicfunctiontestSsi()
163171
{
164172
$container =$this->createContainerFromFile('full');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp