protected function Handler::checkAccess in JSON-RPC 8
Same name and namespace in other branches
- 2.x src/Handler.php \Drupal\jsonrpc\Handler::checkAccess()
Check execution access.
Parameters
\Drupal\jsonrpc\MethodInterface $method: The method for which to check access.
Throws
\Drupal\jsonrpc\Exception\JsonRpcException
1 call to Handler::checkAccess()
- Handler::doExecution in src/
Handler.php - Gets an anonymous function which executes the RPC method.
File
- src/
Handler.php, line 188
Class
- Handler
- Manages all the JSON-RPC business logic.
Namespace
Drupal\jsonrpcCode
protected function checkAccess(MethodInterface $method) {
// TODO: Add cacheability metadata here.
/* @var \Drupal\jsonrpc\MethodInterface $method_definition */
$access_result = $method
->access('execute', NULL, TRUE);
if (!$access_result
->isAllowed()) {
$reason = 'Access Denied';
if ($access_result instanceof AccessResultReasonInterface && ($detail = $access_result
->getReason())) {
$reason .= ': ' . $detail;
}
throw JsonRpcException::fromError(Error::invalidRequest($reason, $access_result));
}
}