protected function EntityShareServerRest::handleGet in Entity Share 7
Handle the GET method action.
Read an entity by UUID.
Overrides EntityShareServerRestAbstract::handleGet
File
- modules/
entity_share_server/ includes/ entity_share_server.rest.inc, line 18 - Class for handling REST request.
Class
- EntityShareServerRest
- Class EntityShareServerRest.
Code
protected function handleGet() {
$entity_type = $this
->getParam('type');
$entity_uuid = $this
->getParam('id');
if (!empty($entity_type)) {
$uuids = array();
if (!empty($entity_uuid)) {
$uuids[] = $entity_uuid;
}
$entities = entity_uuid_load($entity_type, $uuids);
if (!empty($entity_uuid)) {
if (empty($entities)) {
$this
->setError('Entity not found', '404 Not Found');
}
else {
$entity = reset($entities);
$export = new EntityShareEntityExport($entity);
$exported_entity = $export
->execute();
$this
->setResult($exported_entity);
}
}
else {
// @todo Deal with list get.
$this
->setResult($entities);
}
}
else {
// @todo Should we set a more precise error?
$this
->setError('Incorrect parameters');
}
}