diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 00aed40..a9c9898 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 8c800dc..8b85629 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -74,7 +74,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);