Skip to content

Instantly share code, notes, and snippets.

@EuphoryX1
Created May 6, 2013 14:51
Show Gist options
  • Save EuphoryX1/5525643 to your computer and use it in GitHub Desktop.
Save EuphoryX1/5525643 to your computer and use it in GitHub Desktop.
Symfony2 custom exception event
parameters:
euphory.exceptlistener.class: Euphory\StoreBundle\Event\WebExceptionListener
services:
euphory.exceptlistener:
class: %euphory.exceptlistener.class%
arguments: [@mailer,@templating,@logger]
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: 200
<?php
namespace Euphory\StoreBundle\Event;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class WebExceptionListener implements EventSubscriberInterface
{
/**
* @var \Swift_Mailer
*/
protected $mailer;
/**
* @var \Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine
*/
protected $templating;
/**
* @var \Monolog\Logger
*/
protected $logger;
public function __construct($mailer, $templating, $logger)
{
$this->mailer = $mailer;
$this->templating = $templating;
$this->logger = $logger;
}
public function onKernelException(GetResponseForExceptionEvent $event)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment