You are here

protected function RpcRequestFactory::doTransform in JSON-RPC 8

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

Throws

\Drupal\jsonrpc\Exception\JsonRpcException

File

src/Shaper/RpcRequestFactory.php, line 83

Class

RpcRequestFactory
Creates RPC Request objects.

Namespace

Drupal\jsonrpc\Shaper

Code

protected function doTransform($data, Context $context) {
  $context[static::REQUEST_IS_BATCH_REQUEST] = $this
    ->isBatchRequest($data);

  // Treat everything as a batch of requests for uniformity.
  $data = $this
    ->isBatchRequest($data) ? $data : [
    $data,
  ];
  return array_map(function ($item) use ($context) {
    return $this
      ->denormalizeRequest($item, $context);
  }, $data);
}