You are here

function _services_entity_resource_access in Services Entity API 7

1 string reference to '_services_entity_resource_access'
services_entity_services_resources in ./services_entity.services.inc
Implementation of hook_services_resources().

File

./services_entity.resources.inc, line 3

Code

function _services_entity_resource_access($op, $args) {
  if ($op == 'create') {
    list($entity_type) = $args;

    // Pass the entity to the access control.
    return entity_access($op, $entity_type);
  }
  else {

    // Delete, Update.
    list($entity_type, $entity_id) = $args;

    // Load the corresponding entity.
    $entities = entity_load($entity_type, array(
      $entity_data,
    ));
    if (empty($entities)) {
      return FALSE;
    }
    $entity = reset($entities);

    // Pass the entity to the access control.
    return entity_access($op, $entity_type, $entity);
  }
}