vendor/bundles/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/TemplatingPass.php
equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony framework. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * This source file is subject to the MIT license that is bundled |
|
9 * with this source code in the file LICENSE. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler; |
|
13 |
|
14 use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
15 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
16 |
|
17 /** |
|
18 * This pass removes services associated with unused templating engines. |
|
19 * |
|
20 * @author Kris Wallsmith <kris@symfony.com> |
|
21 */ |
|
22 class TemplatingPass implements CompilerPassInterface |
|
23 { |
|
24 public function process(ContainerBuilder $container) |
|
25 { |
|
26 if (!$container->hasDefinition('assetic.asset_manager')) { |
|
27 return; |
|
28 } |
|
29 |
|
30 $engines = $container->getParameterBag()->resolveValue($container->getParameter('templating.engines')); |
|
31 |
|
32 if (!in_array('twig', $engines)) { |
|
33 foreach ($container->findTaggedServiceIds('assetic.templating.twig') as $id => $attr) { |
|
34 $container->removeDefinition($id); |
|
35 } |
|
36 } |
|
37 |
|
38 if (!in_array('php', $engines)) { |
|
39 foreach ($container->findTaggedServiceIds('assetic.templating.php') as $id => $attr) { |
|
40 $container->removeDefinition($id); |
|
41 } |
|
42 } |
|
43 } |
|
44 } |