You are here

protected function Handler::doExecution in JSON-RPC 8

Same name and namespace in other branches
  1. 2.x src/Handler.php \Drupal\jsonrpc\Handler::doExecution()

Gets an anonymous function which executes the RPC method.

Parameters

\Drupal\jsonrpc\Object\Request $request: The JSON-RPC request.

Return value

\Drupal\jsonrpc\Object\Response|null The JSON-RPC response.

Throws

\Drupal\jsonrpc\Exception\JsonRpcException

1 call to Handler::doExecution()
Handler::doRequest in src/Handler.php
Executes an RPC call and returns a JSON-RPC response.

File

src/Handler.php, line 143

Class

Handler
Manages all the JSON-RPC business logic.

Namespace

Drupal\jsonrpc

Code

protected function doExecution(Request $request) {
  if ($method = $this
    ->getMethod($request
    ->getMethod())) {
    $this
      ->checkAccess($method);
    $configuration = [
      HandlerInterface::JSONRPC_REQUEST_KEY => $request,
    ];
    $executable = $this
      ->getExecutable($method, $configuration);
    return $request
      ->hasParams() ? $executable
      ->execute($request
      ->getParams()) : $executable
      ->execute(new ParameterBag([]));
  }
  else {
    throw JsonRpcException::fromError(Error::methodNotFound($method
      ->id()));
  }
}