function _services_postprocess_entities in Services Entity API 7
2 calls to _services_postprocess_entities()
File
- ./
services_entity.resources.inc, line 89
Code
function _services_postprocess_entities($entities, $ordered_results, $fields) {
// Prepare the fields.
$fields = _services_entity_transform_fields($fields);
// Load the full entities.
foreach ($entities as $entity_type => &$entities_of_type) {
$entities_of_type = entity_load($entity_type, array_keys($entities_of_type));
// Allow other modules to modify the returned entities.
drupal_alter('services_entity_postprocess', $entities_of_type, $entity_type);
}
// Now return the entities in the correct order.
$result = array();
foreach ($ordered_results as $partial_entity) {
if (isset($entities[$partial_entity->entity_type][$partial_entity->entity_id])) {
$entity = $entities[$partial_entity->entity_type][$partial_entity->entity_id];
$wrapper = entity_metadata_wrapper($partial_entity->entity_type, $entity);
$entity_result = (object) services_entity_prepare_structure($wrapper, $fields);
if (!empty($entity_result)) {
$entity_result->uri = services_resource_uri(array(
'entity_' . $partial_entity->entity_type,
$partial_entity->entity_id,
));
}
$result[] = $entity_result;
}
}
// Allow other modules to alter the returned result.
drupal_alter('services_entity_postprocess_result', $result, $partial_entity->entity_type);
return $result;
}