Skip to content

Commit

Permalink
Fix error when controller is not an array
Browse files Browse the repository at this point in the history
  • Loading branch information
lopes-vincent committed Oct 4, 2021
1 parent b13bacb commit 3147cda
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions EventListener/RequestListener.php
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\SecurityContext;

class RequestListener implements EventSubscriberInterface
Expand All @@ -22,7 +23,7 @@ public function __construct(
public function markRequestAsOpenApi(ControllerEvent $event): void
{
$controller = $event->getController();
if (isset($controller[0]) && $controller[0] instanceof BaseFrontOpenApiController || $controller[0] instanceof BaseFrontOpenApiController) {
if (is_array($controller) && isset($controller[0]) && $controller[0] instanceof BaseFrontOpenApiController) {
$currentRequest = $event->getRequest();
$currentRequest->attributes->set(OpenApi::OPEN_API_ROUTE_REQUEST_KEY, true);
}
Expand All @@ -31,7 +32,9 @@ public function markRequestAsOpenApi(ControllerEvent $event): void
public static function getSubscribedEvents()
{
return [
KernelEvents::CONTROLLER,
KernelEvents::CONTROLLER => [
['markRequestAsOpenApi', 512],
],
];
}
}

0 comments on commit 3147cda

Please sign in to comment.