You are here

protected static function JsonRpcException::buildResponse in JSON-RPC 2.x

Same name and namespace in other branches
  1. 8 src/Exception/JsonRpcException.php \Drupal\jsonrpc\Exception\JsonRpcException::buildResponse()

Helper to build a JSON-RPC response object.

Parameters

\Drupal\jsonrpc\Object\Error $error: The error object.

mixed $id: The request ID.

string $version: The information version.

Return value

\Drupal\jsonrpc\Object\Response The RPC response object.

2 calls to JsonRpcException::buildResponse()
JsonRpcException::fromError in src/Exception/JsonRpcException.php
Constructs a JsonRpcException from an arbitrary error object.
JsonRpcException::fromPrevious in src/Exception/JsonRpcException.php
Constructs a JsonRpcException from an arbitrary exception.

File

src/Exception/JsonRpcException.php, line 103

Class

JsonRpcException
Custom exception class for the module.

Namespace

Drupal\jsonrpc\Exception

Code

protected static function buildResponse(Error $error, $id = FALSE, $version = NULL) {
  $supported_version = $version ?: \Drupal::service('jsonrpc.handler')
    ->supportedVersion();
  return new Response($supported_version, $id ? $id : NULL, NULL, $error);
}