Indroduce populator service, add providers compiler pass
This commit is contained in:
parent
c128fac685
commit
c56f4e62f5
27
DependencyInjection/Compiler/AddProviderPass.php
Normal file
27
DependencyInjection/Compiler/AddProviderPass.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\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('foq_elastica.populator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$providers = array();
|
||||
foreach ($container->findTaggedServiceIds('foq_elastica.provider') as $id => $attributes) {
|
||||
$providers[] = new Reference($id);
|
||||
}
|
||||
|
||||
$container->getDefinition('foq_elastica.populator')->setArgument(0, $providers);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,16 @@
|
|||
|
||||
namespace FOQ\ElasticaBundle;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use FOQ\ElasticaBundle\DependencyInjection\Compiler\AddProviderPass;
|
||||
|
||||
class FOQElasticaBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container->addCompilerPass(new AddProviderPass());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,16 @@
|
|||
<parameters>
|
||||
<parameter key="foq_elastica.client.class">Elastica_Client</parameter>
|
||||
<parameter key="foq_elastica.index.class">Elastica_Index</parameter>
|
||||
|
||||
<parameter key="foq_elastica.index_manager.class">FOQ\ElasticaBundle\IndexManager</parameter>
|
||||
</parameters>
|
||||
|
||||
|
||||
<services>
|
||||
<service id="foq_elastica.index_manager" class="FOQ\ElasticaBundle\IndexManager">
|
||||
<argument /> <!-- indexes -->
|
||||
</service>
|
||||
<service id="foq_elastica.populator" class="FOQ\ElasticaBundle\Populator">
|
||||
<argument /> <!-- providers -->
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
Loading…
Reference in a new issue