浏览代码

fixed various bugs introduced during the event system migration

Fabien Potencier 14 年之前
父节点
当前提交
1af43a1562

+ 6 - 4
src/Symfony/Bundle/FrameworkBundle/Profiler/ProfilerListener.php

@@ -14,7 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Profiler;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseFromExceptionEvent;
+use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
 use Symfony\Component\HttpFoundation\RequestMatcherInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -61,9 +61,9 @@ class ProfilerListener
     /**
      * Handles the onCoreException event.
      *
-     * @param GetResponseFromExceptionEvent $event A GetResponseFromExceptionEvent instance
+     * @param GetResponseForExceptionEvent $event A GetResponseForExceptionEvent instance
      */
-    public function onCoreException(GetResponseFromExceptionEvent $event)
+    public function onCoreException(GetResponseForExceptionEvent $event)
     {
         if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
             return;
@@ -79,6 +79,8 @@ class ProfilerListener
      */
     public function onCoreResponse(FilterResponseEvent $event)
     {
+        $response = $event->getResponse();
+
         if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
             return $response;
         }
@@ -93,7 +95,7 @@ class ProfilerListener
             $profiler->setParent($parent['request']['profiler']->getToken());
         }
 
-        $profiler->collect($event->getRequest(), $response, $this->exception);
+        $profiler->collect($event->getRequest(), $event->getResponse(), $this->exception);
         $this->exception = null;
     }
 }

+ 6 - 5
src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php

@@ -5,6 +5,7 @@ namespace Symfony\Component\Security\Http\Authorization;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Event\ExceptionEvent;
 use Symfony\Component\Security\Core\Exception\AccessDeniedException;
+use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 
 /**
  * This is used by the ExceptionListener to translate an AccessDeniedException
@@ -17,11 +18,11 @@ interface AccessDeniedHandlerInterface
     /**
      * Handles an access denied failure.
      *
-     * @param ExceptionEvent    $event
-     * @param Request               $request
-     * @param AccessDeniedException $accessDeniedException
+     * @param GetResponseForExceptionEvent $event
+     * @param Request                      $request
+     * @param AccessDeniedException        $accessDeniedException
      *
      * @return Response may return null
      */
-    function handle(ExceptionEvent $event, Request $request, AccessDeniedException $accessDeniedException);
-}
+    function handle(GetResponseForExceptionEvent $event, Request $request, AccessDeniedException $accessDeniedException);
+}

+ 2 - 0
src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php

@@ -27,6 +27,8 @@ use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
+use Symfony\Component\Security\Http\Events;
 
 /**
  * The AbstractAuthenticationListener is the preferred base class for all

+ 4 - 3
src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

@@ -24,6 +24,7 @@ use Symfony\Component\Security\Core\Exception\InsufficientAuthenticationExceptio
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\Events;
+use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 
 /**
@@ -64,9 +65,9 @@ class ExceptionListener
     /**
      * Handles security related exceptions.
      *
-     * @param ExceptionEvent $event An ExceptionEvent instance
+     * @param GetResponseForExceptionEvent $event An GetResponseForExceptionEvent instance
      */
-    public function onCoreException(ExceptionEvent $event)
+    public function onCoreException(GetResponseForExceptionEvent $event)
     {
         $exception = $event->getException();
         $request = $event->getRequest();
@@ -137,7 +138,7 @@ class ExceptionListener
         $event->setResponse($response);
     }
 
-    private function startAuthentication(ExceptionEvent $event, Request $request, AuthenticationException $authException)
+    private function startAuthentication(GetResponseForExceptionEvent $event, Request $request, AuthenticationException $authException)
     {
         $this->context->setToken(null);