public function Response::__construct in JSON-RPC 8
Same name and namespace in other branches
- 2.x src/Object/Response.php \Drupal\jsonrpc\Object\Response::__construct()
Response constructor.
Parameters
string $version: The JSON-RPC version.
mixed $id: The response ID. Must match the ID of the generating request.
mixed $result: A result value. Must not be provided if an error is to be provided.
\Drupal\jsonrpc\Object\Error $error: An error object if the response resulted in an error. Must not be provided if a result was provided.
File
- src/
Object/ Response.php, line 63
Class
- Response
- Response object to help implement JSON RPC's spec for response objects.
Namespace
Drupal\jsonrpc\ObjectCode
public function __construct($version, $id, $result = NULL, Error $error = NULL) {
$this
->assertValidResponse($version, $id, $result, $error);
$this->version = $version;
$this->id = $id;
if (!is_null($result)) {
$this->result = $result;
}
else {
$this->error = $error;
$this
->setCacheability($error);
}
}