vendor/symfony/src/Symfony/Bundle/MonologBundle/DependencyInjection/Compiler/DebugHandlerPass.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
       
    13 
       
    14 use Symfony\Component\DependencyInjection\Reference;
       
    15 use Symfony\Component\DependencyInjection\ContainerBuilder;
       
    16 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
       
    17 use Symfony\Component\DependencyInjection\Definition;
       
    18 use Monolog\Logger;
       
    19 
       
    20 /**
       
    21  * Adds the DebugHandler when the profiler is enabled.
       
    22  *
       
    23  * @author Christophe Coevoet <stof@notk.org>
       
    24  */
       
    25 class DebugHandlerPass implements CompilerPassInterface
       
    26 {
       
    27     public function process(ContainerBuilder $container)
       
    28     {
       
    29         if (!$container->hasDefinition('monolog.logger_prototype') || !$container->hasDefinition('profiler')) {
       
    30             return;
       
    31         }
       
    32 
       
    33         $debugHandler = new Definition('%monolog.handler.debug.class%', array(Logger::DEBUG, true));
       
    34         $container->setDefinition('monolog.handler.debug', $debugHandler);
       
    35         $container->getDefinition('monolog.logger_prototype')->addMethodCall('pushHandler', array (new Reference('monolog.handler.debug')));
       
    36     }
       
    37 }