diff --git a/EventListener/RouterListener.php b/EventListener/RouterListener.php index 0137f28..bf2ad05 100644 --- a/EventListener/RouterListener.php +++ b/EventListener/RouterListener.php @@ -2,6 +2,7 @@ namespace Tactics\LegacyBridgeBundle\EventListener; +use Exception; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; @@ -35,13 +36,12 @@ class RouterListener implements EventSubscriberInterface */ protected $logger; - /** * @param SymfonyRouterListener $routerListener - * @param LegacyKernelInterface $legacyKernel - * @param LoggerInterface $logger + * @param LegacyKernelInterface|null $legacyKernel + * @param LoggerInterface|null $logger */ - public function __construct(SymfonyRouterListener $routerListener, LegacyKernelInterface $legacyKernel=null, LoggerInterface $logger=null) + public function __construct(SymfonyRouterListener $routerListener, LegacyKernelInterface $legacyKernel=NULL, LoggerInterface $logger=NULL) { $this->legacyKernel = $legacyKernel; $this->routerListener = $routerListener; @@ -49,12 +49,11 @@ public function __construct(SymfonyRouterListener $routerListener, LegacyKernelI }//end __construct() - /** - * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event + * @param RequestEvent $event * - * @return \Symfony\Component\HttpKernel\Event\RequestEvent - * @throws \Exception + * @return RequestEvent + * @throws Exception */ public function onKernelRequest(RequestEvent $event) { @@ -63,31 +62,27 @@ public function onKernelRequest(RequestEvent $event) $this->routerListener->onKernelRequest($event); } catch (NotFoundHttpException $e) { // Optionally we log the request that go through the legacy controller. - if ($this->logger !== null) { + if ($this->logger !== NULL) { $message = 'Request handled by the '.$this->legacyKernel->getName().' kernel.'; $this->logger->info($message); } - if ($this->legacyKernel !== null) { - + if ($this->legacyKernel !== NULL) { // When the request could not be dispatched through symfony 5 // we fallback to our legacy kernel to dispatch the request. $response = $this->legacyKernel->handle( $event->getRequest(), $event->getRequestType(), - true + TRUE ); - if ($response->getStatusCode() !== 404) { - $event->setResponse($response); - return $event; - } + $event->setResponse($response); + return $event; } - } + }//end try }//end onKernelRequest() - /** * @param FinishRequestEvent $event */ @@ -97,7 +92,6 @@ public function onKernelFinishRequest(FinishRequestEvent $event) }//end onKernelFinishRequest() - /** * @{inheritdoc} */ @@ -125,5 +119,4 @@ public static function getSubscribedEvents() }//end getSubscribedEvents() - }//end class