public function JsonRpcOptionsRequestSubscriber::onRequest in JSON-RPC 2.x
Tries to handle the options request.
Parameters
\Symfony\Component\HttpKernel\Event\KernelEvent $event: The request event.
File
- src/
Routing/ JsonRpcOptionsRequestSubscriber.php, line 48
Class
- JsonRpcOptionsRequestSubscriber
- Handles options requests.
Namespace
Drupal\jsonrpc\RoutingCode
public function onRequest(KernelEvent $event) {
$request = $event
->getRequest();
if (!$request
->isMethod('OPTIONS') || $request->headers
->get('access-control-request-method') === 'POST') {
return;
}
$routes = $this->routeProvider
->getRouteCollectionForRequest($request);
// If all routes are for JSON-RPC let the module handle them.
$all_jsonrpc = array_reduce(array_keys($routes
->all()), function (bool $carry, string $route_name) {
return $carry && $route_name === 'jsonrpc.handler';
}, TRUE);
if (!$all_jsonrpc) {
$this->subject
->onRequest($event);
}
}