FOSElasticaBundle/DependencyInjection/Compiler/AddProviderPass.php
2013-03-27 13:44:44 -04:00

28 lines
803 B
PHP

<?php
namespace FOS\ElasticaBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
class AddProviderPass implements CompilerPassInterface
{
/**
* {@inheritDoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('fos_elastica.populator')) {
return;
}
$providers = array();
foreach ($container->findTaggedServiceIds('fos_elastica.provider') as $id => $attributes) {
$providers[$id] = new Reference($id);
}
$container->getDefinition('fos_elastica.populator')->replaceArgument(0, $providers);
}
}