Skip to content

Commit fc3cb0b

Browse files
committed
bug symfony#19120 [FrameworkBundle] templating can be fully disabled (xabbuh)
This PR was submitted for the master branch but it was merged into the 3.1 branch instead (closes symfony#19120). Discussion ---------- [FrameworkBundle] templating can be fully disabled | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#19052 | License | MIT | Doc PR | Commits ------- 92a7f10 [FrameworkBundle] templating can be fully disabled
2 parents 04f2659 + 92a7f10 commit fc3cb0b

File tree

6 files changed

+33
-2
lines changed

6 files changed

+33
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
320320
->arrayNode('templating')
321321
->info('templating configuration')
322322
->canBeEnabled()
323+
->beforeNormalization()
324+
->ifTrue(function ($v) { return false === $v || is_array($v) && false === $v['enabled']; })
325+
->then(function () { return array('enabled' => false, 'engines' => false); })
326+
->end()
323327
->children()
324328
->scalarNode('hinclude_default_template')->defaultNull()->end()
325329
->scalarNode('cache')->end()
@@ -346,8 +350,9 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
346350
->example(array('twig'))
347351
->isRequired()
348352
->requiresAtLeastOneElement()
353+
->canBeUnset()
349354
->beforeNormalization()
350-
->ifTrue(function ($v) { return !is_array($v); })
355+
->ifTrue(function ($v) { return !is_array($v) && false !== $v; })
351356
->then(function ($v) { return array($v); })
352357
->end()
353358
->prototype('scalar')->end()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,11 @@
147147
<xsd:complexType name="templating">
148148
<xsd:sequence>
149149
<xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
150-
<xsd:element name="engine" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
150+
<xsd:element name="engine" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
151151
<xsd:element name="form" type="form-resources" minOccurs="0" maxOccurs="1" />
152152
</xsd:sequence>
153153

154+
<xsd:attribute name="enabled" type="xsd:boolean" />
154155
<xsd:attribute name="cache" type="xsd:string" />
155156
<xsd:attribute name="hinclude-default-template" type="xsd:string" />
156157
</xsd:complexType>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'templating' => false,
5+
));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="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 http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:templating enabled="false" />
10+
</framework:config>
11+
</container>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
framework:
2+
templating: false

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ public function testTemplating()
208208
$this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template');
209209
}
210210

211+
public function testTemplatingCanBeDisabled()
212+
{
213+
$container = $this->createContainerFromFile('templating_disabled');
214+
215+
$this->assertFalse($container->hasParameter('templating.engines'), '"templating.engines" container parameter is not registered when templating is disabled.');
216+
}
217+
211218
public function testAssets()
212219
{
213220
$container = $this->createContainerFromFile('assets');

0 commit comments

Comments
 (0)