Skip to content

Instantly share code, notes, and snippets.

@stof
Created February 20, 2012 22:33
Show Gist options
  • Save stof/1871975 to your computer and use it in GitHub Desktop.
Save stof/1871975 to your computer and use it in GitHub Desktop.
Lazy listener setup
<?php
/**
* Gets the 'event_dispatcher' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher A Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher instance.
*/
protected function getEventDispatcherService()
{
$this->services['event_dispatcher'] = $instance = new \Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher($this, $this->get('debug.stopwatch'), $this->get('monolog.logger.event'));
$instance->addListenerService('kernel.controller', array(0 => 'data_collector.request', 1 => 'onKernelController'), 0);
$instance->addListenerService('kernel.response', array(0 => 'monolog.handler.firephp', 1 => 'onKernelResponse'), 0);
$instance->addListenerService('kernel.request', array(0 => 'security.firewall', 1 => 'onKernelRequest'), 8);
$instance->addListenerService('kernel.response', array(0 => 'security.rememberme.response_listener', 1 => 'onKernelResponse'), 0);
$instance->addListenerService('kernel.response', array(0 => 'tolkiendil.ajax_listener', 1 => 'onKernelResponse'), 0);
$instance->addListenerService('kernel.response', array(0 => 'web_profiler.debug_toolbar', 1 => 'onKernelResponse'), -128);
$instance->addListenerService('kernel.response', array(0 => 'sf2gen.toolbar', 1 => 'onKernelResponse'), -128);
$instance->addSubscriberService('response_listener', 'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener');
$instance->addSubscriberService('streamed_response_listener', 'Symfony\\Component\\HttpKernel\\EventListener\\StreamedResponseListener');
$instance->addSubscriberService('locale_listener', 'Symfony\\Component\\HttpKernel\\EventListener\\LocaleListener');
$instance->addSubscriberService('session_listener', 'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener');
$instance->addSubscriberService('profiler_listener', 'Symfony\\Component\\HttpKernel\\EventListener\\ProfilerListener');
$instance->addSubscriberService('router_listener', 'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener');
$instance->addSubscriberService('twig.exception_listener', 'Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener');
return $instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment