minor #13667 made the assets optional (fabpot)

This PR was merged into the 2.7 branch.

Discussion
----------

made the assets optional

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

Right now, the assets configuration is optional (and the dependency as well on FramewokrBundle), but the asset services and the Asset extension is always loaded. This PR fixes this inconsistency, which will make tests pass again.

Commits
-------

ddf5ac4 made the assets optional
This commit is contained in:
Fabien Potencier 2015-02-12 14:07:11 +01:00
commit a0a0b05bb5
4 changed files with 6 additions and 3 deletions

View File

@ -49,7 +49,6 @@ class FrameworkExtension extends Extension
$loader->load('web.xml');
$loader->load('services.xml');
$loader->load('fragment_renderer.xml');
$loader->load('assets.xml');
// A translator must always be registered (as support is included by
// default in the Form component). If disabled, an identity translator
@ -562,6 +561,8 @@ class FrameworkExtension extends Extension
*/
private function registerAssetsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
$loader->load('assets.xml');
$defaultVersion = $this->createVersion($container, $config['version'], $config['version_format'], '_default');
$defaultPackage = $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);

View File

@ -4,7 +4,6 @@
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}{% endblock %}
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" />
</head>
<body>
{% block body %}{% endblock %}

View File

@ -78,6 +78,10 @@ class ExtensionPass implements CompilerPassInterface
$container->setDefinition('twig.loader.filesystem', $loader);
}
if ($container->has('assets.packages')) {
$loader->addTag('twig.extension');
}
if (method_exists('Symfony\Bridge\Twig\AppVariable', 'setContainer')) {
// we are on Symfony <3.0, where the setContainer method exists
$container->getDefinition('twig.app_variable')->addMethodCall('setContainer', array(new Reference('service_container')));

View File

@ -86,7 +86,6 @@
</service>
<service id="twig.extension.assets" class="Symfony\Bridge\Twig\Extension\AssetExtension" public="false">
<tag name="twig.extension" />
<argument type="service" id="assets.packages" />
<argument type="service" id="twig.extension.httpfoundation" />
</service>