protected function EntityParameterFactory::doTransform in JSON-RPC 8
Same name and namespace in other branches
- 2.x src/ParameterFactory/EntityParameterFactory.php \Drupal\jsonrpc\ParameterFactory\EntityParameterFactory::doTransform()
File
- src/
ParameterFactory/ EntityParameterFactory.php, line 77
Class
- EntityParameterFactory
- A factory to create loaded entities from entity type & UUID user input.
Namespace
Drupal\jsonrpc\ParameterFactoryCode
protected function doTransform($data, Context $context = NULL) {
try {
if ($entity = $this->entityRepository
->loadEntityByUuid($data['type'], $data['uuid'])) {
return $entity;
}
throw JsonRpcException::fromError(Error::invalidParams('The requested entity could not be found.'));
} catch (EntityStorageException $e) {
throw JsonRpcException::fromError(Error::invalidParams('This entity type is not supported. Error: ' . $e
->getMessage()));
}
}