浏览代码

[MonologBundle] Added an exception when a handler is named "debug"

Christophe Coevoet 14 年之前
父节点
当前提交
d5f2bc5d5a

+ 4 - 0
src/Symfony/Bundle/MonologBundle/DependencyInjection/Configuration.php

@@ -71,6 +71,10 @@ class Configuration
                             ->thenInvalid('The id has to be specified to use a service as handler')
                         ->end()
                     ->end()
+                    ->validate()
+                        ->ifTrue(function($v) { return isset($v['debug']); })
+                        ->thenInvalid('The "debug" name cannot be used as it is reserved for the handler of the profiler')
+                    ->end()
                 ->end()
             ->end()
             ->append($this->getProcessorsNode())

+ 12 - 0
src/Symfony/Bundle/MonologBundle/Tests/DependencyInjection/MonologExtensionTest.php

@@ -83,6 +83,18 @@ class MonologExtensionTest extends TestCase
         $this->assertDICConstructorArguments($handler, array(new Reference('monolog.handler.nested'), \Monolog\Logger::ERROR, 0, false));
     }
 
+    /**
+     * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
+     */
+    public function testExceptionWhenUsingDebugName()
+    {
+        // logger
+        $container = new ContainerBuilder();
+        $loader = new MonologExtension();
+
+        $loader->load(array(array('handlers' => array('debug' => array('type' => 'stream')))), $container);
+    }
+
     /**
      * Assertion on the Class of a DIC Service Definition.
      *