Do not clobber existing client definitions (closes #336 and #324)

While we could have used an abstract definition, its ID would likely conflict with the alias we set for the default client. Remove the abstract definition altogether and simply construct new definitions for each client. This resolves the previous issue where multiple clients would overwrite the constructor arguments of the previous definition.
This commit is contained in:
Jeremy Mikola 2013-07-12 17:58:13 -04:00
parent 604193396f
commit 74d993b642
2 changed files with 2 additions and 10 deletions

View file

@ -70,10 +70,9 @@ class FOSElasticaExtension extends Extension
{
$clientIds = array();
foreach ($clients as $name => $clientConfig) {
$clientDef = $container->getDefinition('fos_elastica.client');
$clientDef->replaceArgument(0, $clientConfig);
$clientId = sprintf('fos_elastica.client.%s', $name);
$clientDef = new Definition('%fos_elastica.client.class%', array($clientConfig));
$clientDef->addMethodCall('setLogger', array(new Reference('fos_elastica.logger')));
$container->setDefinition($clientId, $clientDef);

View file

@ -27,13 +27,6 @@
<argument type="service" id="fos_elastica.logger" />
</service>
<service id="fos_elastica.client" class="%fos_elastica.client.class%">
<argument /> <!-- config -->
<call method="setLogger">
<argument type="service" id="fos_elastica.logger" />
</call>
</service>
<service id="fos_elastica.index_manager" class="FOS\ElasticaBundle\IndexManager">
<argument /> <!-- indexes -->
<argument /> <!-- default index -->