Skip to content

Commit

Permalink
RFC: Move REST route recognition after routing resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Aug 30, 2024
1 parent c9338e4 commit 759a247
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/bundle/EventListener/RequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public static function getSubscribedEvents(): array
{
return [
// 10001 is to ensure that REST requests are tagged before CorsListener is called
KernelEvents::REQUEST => ['onKernelRequest', 10001],
KernelEvents::REQUEST => [
['onKernelRequest', 10001],
['addAttributeForIbexaRestRoute', 30],
],
];
}

Expand All @@ -57,6 +60,15 @@ public function onKernelRequest(RequestEvent $event): void
);
}

public function addAttributeForIbexaRestRoute(RequestEvent $event): void
{
$path = $event->getRequest()->attributes->get('semanticPathinfo');
$event->getRequest()->attributes->set(
'is_rest_request',
$this->uriParser->hasRestPrefix($path)
);
}

/**
* @param \Symfony\Component\HttpFoundation\Request $request
*
Expand Down

0 comments on commit 759a247

Please sign in to comment.