You are here

function _services_entity_resource_index in Services Entity API 7

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

File

./services_entity.resources.inc, line 69

Code

function _services_entity_resource_index($entity_type, $page, $bundle, $fields, $page_size) {

  // Build an EFQ based on the arguments.
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', $entity_type)
    ->range($page * $page_size, $page_size);
  if (!empty($bundle)) {
    $query
      ->entityCondition('bundle', $bundle, '=');
  }
  $entities = $query
    ->execute();
  if (empty($entities)) {
    return services_error(t('No entities found.'), 404);
  }
  return _services_postprocess_entities($entities, $query->ordered_results, $fields);
}