bug #24706 [DependencyInjection] Add the possibility to disable assets via xml (renatomefi)

This PR was merged into the 3.3 branch.

Discussion
----------

[DependencyInjection] Add the possibility to disable assets via xml

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | no
| License       | MIT
| Doc PR        | no

- When trying to disable the assets using xml configuration I realized it wasn't possible, this patch fixes and tests it
- Also added extra tests since the assets being disabled was being tested on both php and yaml Extension tests

Commits
-------

8579e24 [FrameworkBundle] Allow to disable assets via framework:assets xml configuration
This commit is contained in:
Nicolas Grekas 2017-10-28 18:26:49 +02:00
commit e80cf9cade
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');