[FrameworkBundle] Allow to disable assets via framework:assets xml configuration

This commit is contained in:
Renato Mendes Figueiredo 2017-10-27 14:47:38 +02:00
parent 4910ac6fe9
commit 8579e24750
5 changed files with 30 additions and 0 deletions

View File

@ -138,6 +138,7 @@
<xsd:element name="package" type="package" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="base-path" type="xsd:string" />
<xsd:attribute name="version-strategy" type="xsd:string" />
<xsd:attribute name="version" type="xsd:string" />

View File

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

View File

@ -0,0 +1,12 @@
<?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:assets enabled="false" />
</framework:config>
</container>

View File

@ -0,0 +1,3 @@
framework:
assets:
enabled: false

View File

@ -423,6 +423,13 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1));
}
public function testAssetsCanBeDisabled()
{
$container = $this->createContainerFromFile('assets_disabled');
$this->assertFalse($container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.');
}
public function testWebLink()
{
$container = $this->createContainerFromFile('web_link');