You are here

public function ServicesEntityResourceControllerClean::index in Services Entity API 7.2

Implements ServicesResourceControllerInterface::index().

Overrides ServicesEntityResourceController::index

File

plugins/services_entity_resource_clean.inc, line 109

Class

ServicesEntityResourceControllerClean
This class is designed to create a very clean API that integrates with the services and entity modules. We want to strip all "drupalisms" out of the API. For example, there should be no [LANGUAGE_NONE][0][value] or field_ in the API.

Code

public function index($entity_type, $fields, $parameters, $page, $pagesize, $sort, $direction) {
  $property_info = entity_get_all_property_info($entity_type);
  $parameters = $this
    ->transform_values($entity_type, $property_info, $parameters);
  $sort = isset($property_info['field_' . $sort]) ? 'field_' . $sort : $sort;

  // Call the parent method, which takes care of access control.
  $entities = parent::index($entity_type, '*', $parameters, $page, $pagesize, $sort, $direction);
  foreach ($entities as $entity) {
    $return[] = $this
      ->get_data(entity_metadata_wrapper($entity_type, $entity), $fields);
  }
  return $return;
}