Skip to content

Commit

Permalink
bug #24706 [DependencyInjection] Add the possibility to disable asset…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
nicolas-grekas committed Oct 28, 2017
2 parents 91d2690 + 8579e24 commit e80cf9c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
Expand Up @@ -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" />
Expand Down
@@ -0,0 +1,7 @@
<?php

$container->loadFromExtension('framework', array(
'assets' => array(
'enabled' => false,
),
));
@@ -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>
@@ -0,0 +1,3 @@
framework:
assets:
enabled: false
Expand Up @@ -423,6 +423,13 @@ public function testAssetsDefaultVersionStrategyAsService()
$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');
Expand Down

0 comments on commit e80cf9c

Please sign in to comment.