[DoctrineMongoDBBundle] made it possible to disable logging

This commit is contained in:
Kris Wallsmith 2011-03-11 13:20:16 -08:00
parent e0b46fea73
commit 7b3fbb46c2
2 changed files with 19 additions and 3 deletions

View File

@ -12,10 +12,21 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
*/
class Configuration
{
private $debug;
/**
* Constructor.
*
* @param Boolean $debug The kernel.debug value
*/
public function __construct($debug)
{
$this->debug = (Boolean) $debug;
}
/**
* Generates the configuration tree.
*
* @param boolean $kernelDebug The kernel.debug DIC parameter
* @return \Symfony\Component\DependencyInjection\Configuration\NodeInterface
*/
public function getConfigTree()
@ -54,6 +65,7 @@ class Configuration
->builder($this->getMetadataCacheDriverNode())
->scalarNode('connection')->end()
->scalarNode('database')->end()
->booleanNode('logging')->defaultValue($this->debug)->end()
->fixXmlConfig('mapping')
->builder($this->getMappingsNode())
->end()

View File

@ -66,7 +66,7 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
$loader->load('mongodb.xml');
$processor = new Processor();
$configuration = new Configuration();
$configuration = new Configuration($container->getParameter('kernel.debug'));
$config = $processor->process($configuration->getConfigTree(), $configs);
// can't currently default this correctly in Configuration
@ -177,8 +177,12 @@ class DoctrineMongoDBExtension extends AbstractDoctrineExtension
'setHydratorNamespace' => '%doctrine.odm.mongodb.hydrator_namespace%',
'setAutoGenerateHydratorClasses' => '%doctrine.odm.mongodb.auto_generate_hydrator_classes%',
'setDefaultDB' => $defaultDatabase,
'setLoggerCallable' => array(new Reference('doctrine.odm.mongodb.logger'), 'logQuery'),
);
if ($documentManager['logging']) {
$methods['setLoggerCallable'] = array(new Reference('doctrine.odm.mongodb.logger'), 'logQuery');
}
foreach ($methods as $method => $arg) {
if ($odmConfigDef->hasMethodCall($method)) {
$odmConfigDef->removeMethodCall($method);