public function ServicesClientUUIDResourceController::access in Services Client 7.2
Implements ServicesResourceControllerInterface::access().
Overrides ServicesEntityResourceController::access
File
- services_client_services/
includes/ ServicesClientUUIDResourceController.inc, line 13 - Custom controller to allow handling requests with UUIDs.
Class
- ServicesClientUUIDResourceController
- @file Custom controller to allow handling requests with UUIDs.
Code
public function access($op, $args) {
if ($op == 'index') {
// Access is handled per-entity by index().
return TRUE;
}
if ($op == 'create') {
list($entity_type) = $args;
// Workaround for bug in Entity API node access.
// @todo remove once https://drupal.org/node/1780646 lands.
if ($entity_type === 'node') {
return isset($args['type']) ? node_access('create', $args['type']) : FALSE;
}
// Create an entity from the data and pass this to entity_access(). This
// allows us to check per-bundle creation rights.
$entity = entity_create($entity_type, $args);
$result = entity_access($op, $entity_type, $entity);
// NULL result means that entity type don't have access check function.
return $result !== NULL ? $result : TRUE;
}
else {
// Retrieve, Delete, Update.
list($entity_type, $entity_id) = $args;
$entity_id = $this
->normalizeEntityId($entity_type, $entity_id);
$entity = entity_load_single($entity_type, $entity_id);
// Pass the entity to the access control.
$result = entity_access($op, $entity_type, $entity ? $entity : NULL);
// NULL result means that entity type don't have access check function.
return $result !== NULL ? $result : TRUE;
}
}