From 759950aff66092489a5d40f79d2c5c2aea1a9194 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Mon, 4 Nov 2013 17:24:35 +0200 Subject: [PATCH] Add option to disable logger or specify different logger service --- DependencyInjection/Configuration.php | 13 ++++++++++--- DependencyInjection/FOSElasticaExtension.php | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 8a067b5..e05dd2e 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -76,8 +76,9 @@ class Configuration implements ConfigurationInterface return array( 'servers' => array( array( - 'host' => $v['host'], - 'port' => $v['port'], + 'host' => $v['host'], + 'port' => $v['port'], + 'logger' => $v['logger'] ) ) ); @@ -89,7 +90,8 @@ class Configuration implements ConfigurationInterface return array( 'servers' => array( array( - 'url' => $v['url'], + 'url' => $v['url'], + 'logger' => $v['logger'] ) ) ); @@ -102,6 +104,11 @@ class Configuration implements ConfigurationInterface ->scalarNode('url')->end() ->scalarNode('host')->end() ->scalarNode('port')->end() + ->scalarNode('logger') + ->defaultValue('fos_elastica.logger') + ->treatNullLike('fos_elastica.logger') + ->treatTrueLike('fos_elastica.logger') + ->end() ->end() ->end() ->end() diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index eb6dd4d..bcf8e84 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -73,7 +73,10 @@ class FOSElasticaExtension extends Extension foreach ($clients as $name => $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'))); + $logger = $clientConfig['servers'][0]['logger']; + if (false !== $logger) { + $clientDef->addMethodCall('setLogger', array(new Reference($logger))); + } $clientDef->addTag('fos_elastica.client'); $container->setDefinition($clientId, $clientDef);