[FrameworkBundle] templating can be fully disabled

This commit is contained in:
Christian Flothmann 2016-06-20 18:01:23 +02:00 committed by Fabien Potencier
parent 04f265911e
commit 92a7f10de5
6 changed files with 33 additions and 2 deletions

View File

@ -320,6 +320,10 @@ class Configuration implements ConfigurationInterface
->arrayNode('templating')
->info('templating configuration')
->canBeEnabled()
->beforeNormalization()
->ifTrue(function ($v) { return false === $v || is_array($v) && false === $v['enabled']; })
->then(function () { return array('enabled' => false, 'engines' => false); })
->end()
->children()
->scalarNode('hinclude_default_template')->defaultNull()->end()
->scalarNode('cache')->end()
@ -346,8 +350,9 @@ class Configuration implements ConfigurationInterface
->example(array('twig'))
->isRequired()
->requiresAtLeastOneElement()
->canBeUnset()
->beforeNormalization()
->ifTrue(function ($v) { return !is_array($v); })
->ifTrue(function ($v) { return !is_array($v) && false !== $v; })
->then(function ($v) { return array($v); })
->end()
->prototype('scalar')->end()

View File

@ -147,10 +147,11 @@
<xsd:complexType name="templating">
<xsd:sequence>
<xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="engine" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
<xsd:element name="engine" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="form" type="form-resources" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="cache" type="xsd:string" />
<xsd:attribute name="hinclude-default-template" type="xsd:string" />
</xsd:complexType>

View File

@ -0,0 +1,5 @@
<?php
$container->loadFromExtension('framework', array(
'templating' => false,
));

View File

@ -0,0 +1,11 @@
<?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 http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:templating enabled="false" />
</framework:config>
</container>

View File

@ -0,0 +1,2 @@
framework:
templating: false

View File

@ -208,6 +208,13 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template');
}
public function testTemplatingCanBeDisabled()
{
$container = $this->createContainerFromFile('templating_disabled');
$this->assertFalse($container->hasParameter('templating.engines'), '"templating.engines" container parameter is not registered when templating is disabled.');
}
public function testAssets()
{
$container = $this->createContainerFromFile('assets');