[WebProfilerBundle] made WebDebugToolbarListener implement EventSubscriberInterface

This commit is contained in:
Fabien Potencier 2012-07-15 15:41:19 +02:00
parent 93cbdfdd62
commit b255db5ca0
2 changed files with 12 additions and 3 deletions

View File

@ -12,10 +12,12 @@
namespace Symfony\Bundle\WebProfilerBundle\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
/**
* WebDebugToolbarListener injects the Web Debug Toolbar.
@ -27,7 +29,7 @@ use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class WebDebugToolbarListener
class WebDebugToolbarListener implements EventSubscriberInterface
{
const DISABLED = 1;
const ENABLED = 2;
@ -124,4 +126,11 @@ class WebDebugToolbarListener
$response->setContent($content);
}
}
public static function getSubscribedEvents()
{
return array(
KernelEvents::RESPONSE => array('onKernelResponse', -128),
);
}
}

View File

@ -10,7 +10,7 @@
<services>
<service id="web_profiler.debug_toolbar" class="%web_profiler.debug_toolbar.class%">
<tag name="kernel.event_listener" event="kernel.response" method="onKernelResponse" priority="-128" />
<tag name="kernel.event_subscriber" />
<argument type="service" id="templating.engine.twig" />
<argument>%web_profiler.debug_toolbar.intercept_redirects%</argument>
<argument>%web_profiler.debug_toolbar.mode%</argument>