summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Http/Firewall/ContextListener.php4
-rw-r--r--Http/Firewall/ExceptionListener.php4
2 files changed, 7 insertions, 1 deletions
diff --git a/Http/Firewall/ContextListener.php b/Http/Firewall/ContextListener.php
index 8c71876..81ccbdc 100644
--- a/Http/Firewall/ContextListener.php
+++ b/Http/Firewall/ContextListener.php
@@ -38,6 +38,7 @@ class ContextListener implements ListenerInterface
private $logger;
private $userProviders;
private $dispatcher;
+ private $registered;
public function __construct(SecurityContextInterface $context, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
@@ -65,8 +66,9 @@ class ContextListener implements ListenerInterface
*/
public function handle(GetResponseEvent $event)
{
- if (null !== $this->dispatcher && HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
+ if (!$this->registered && null !== $this->dispatcher && HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$this->dispatcher->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse'));
+ $this->registered = true;
}
$request = $event->getRequest();
diff --git a/Http/Firewall/ExceptionListener.php b/Http/Firewall/ExceptionListener.php
index 6554595..abbb460 100644
--- a/Http/Firewall/ExceptionListener.php
+++ b/Http/Firewall/ExceptionListener.php
@@ -76,6 +76,10 @@ class ExceptionListener
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
+ // we need to remove ourselves as the exception listener can be
+ // different depending on the Request
+ $event->getDispatcher()->removeListener(KernelEvents::EXCEPTION, array($this, 'onKernelException'));
+
$exception = $event->getException();
$request = $event->getRequest();