Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when controller is not an array #37

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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],
],
];
}
}