protected function RpcResponseFactory::doTransform in JSON-RPC 2.x
Same name and namespace in other branches
- 8 src/Shaper/RpcResponseFactory.php \Drupal\jsonrpc\Shaper\RpcResponseFactory::doTransform()
File
- src/
Shaper/ RpcResponseFactory.php, line 84
Class
- RpcResponseFactory
- Creates RPC Response objects.
Namespace
Drupal\jsonrpc\ShaperCode
protected function doTransform($data, Context $context) {
$this
->setOutputSchema($data[0]
->getResultSchema());
$output = array_map(function (Response $response) use ($context) {
try {
return $this
->doNormalize($response, $context);
} catch (\Exception $e) {
return JsonRpcException::fromPrevious($e, $response
->id(), $context[static::RESPONSE_VERSION_KEY]);
}
}, $data);
return $context[static::REQUEST_IS_BATCH_REQUEST] ? $output : reset($output);
}