public function ServicesEntityResourceControllerClean::field in Services Entity API 7.2
Implements ServicesResourceControllerInterface::field().
Overrides ServicesEntityResourceController::field
File
- plugins/
services_entity_resource_clean.inc, line 125
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 field($entity_type, $entity_id, $field_name, $fields = '*', $raw = FALSE) {
$entity = entity_load_single($entity_type, $entity_id);
if (!$entity) {
services_error('Entity not found', 404);
}
$field_name = preg_replace('/^field_/', '', $field_name);
// The metadata wrapper checks entity_access() on each entity in the field.
$return = $this
->get_data(entity_metadata_wrapper($entity_type, $entity), $field_name);
return $return;
}