From f7b7288892f4d2bf6c5aa1dd0f8d71f772d05ab2 Mon Sep 17 00:00:00 2001 From: Kris Wallsmith Date: Wed, 2 Mar 2011 08:11:11 -0500 Subject: [PATCH] [AsseticBundle] added compiler pass for factory workers --- .../Compiler/AssetFactoryPass.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/AssetFactoryPass.php diff --git a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/AssetFactoryPass.php b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/AssetFactoryPass.php new file mode 100644 index 000000000000..04390f1920de --- /dev/null +++ b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Compiler/AssetFactoryPass.php @@ -0,0 +1,36 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Adds services tagged as workers to the asset factory. + * + * @author Kris Wallsmith + */ +class AssetFactoryPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('assetic.asset_factory')) { + return; + } + + $factory = $container->getDefinition('assetic.asset_factory'); + foreach ($container->findTaggedServiceIds('assetic.factory_worker') as $id => $attr) { + $factory->addMethodCall('addWorker', array(new Reference($id))); + } + } +}