El oyente debería detectar eso: no conozco ninguna forma de especificar un oyente para un solo paquete.
<?
namespace Your\MainBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
class YourExceptionListener
{
public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
$namespace = new \ReflectionObject($event->getController())->getNamespaceName();
switch ($namespace)
{
case 'Acme\\DemoBundle':
// do whatever with $exception here
break;
case 'Some\\OtherBundle':
// do whatever with $exception here
break;
case 'Your\\MainBundle':
// do whatever with $exception here
break;
default;
// default
}
}
}
y registrarlo
//services.yml
kernel.listener.yourlistener:
class: Your\MainBundle\YourExceptionListener
tags:
- { name: kernel.event_listener, event: kernel.exception, method: onKernelException }