You are here

function _services_entity_transform_fields in Services Entity API 7

Recursive function to get all fields and the children of those fields noted by field_name:child_name.

3 calls to _services_entity_transform_fields()
ServicesEntityBasic::assertFieldPropertyFetching in tests/services_entity.test
ServicesEntityBasic::testPropertyFetching in tests/services_entity.test
_services_postprocess_entities in ./services_entity.resources.inc

File

./services_entity.resources.inc, line 139

Code

function _services_entity_transform_fields(array $fields) {
  $transformed_fields = array();
  foreach ($fields as $field) {
    if (!strpos($field, ':') == 0) {
      list($parent, $child) = explode(':', $field, 2);
      $value = _services_entity_transform_fields(array(
        $child,
      ));
      $transformed_fields[$parent] = isset($transformed_fields[$parent]) ? array_merge_recursive($transformed_fields[$parent], $value) : $value;
    }
    else {
      $transformed_fields[$field] = $field;
    }
  }
  return $transformed_fields;
}