function cer_get_field_collection_owner in Corresponding Entity References 7.3
Gets the ultimate owner of a field collection -- that is, the top-level entity under which it's embedded. This could be any kind of entity that's not a field collection item.
1 string reference to 'cer_get_field_collection_owner'
- cer_entity_property_info_alter in ./
cer.module - Implements hook_entity_property_info_alter().
File
- ./
cer.properties.field_collection.inc, line 63 - Contains entity property callback functions for the 'cer' struct exposed to Entity API on field collections.
Code
function cer_get_field_collection_owner(array $data, array $options, $property, $data_type, array $info) {
// If the entity is a field collection item, recurse upward. Otherwise,
// return the wrapped entity.
if ($data[0] == 'field_collection_item') {
$data[0] = $data[1]
->hostEntityType();
$data[1] = $data[1]
->hostEntity();
$self = __FUNCTION__;
return $self($data, $options, $property, $data_type, $info);
}
else {
return new EntityDrupalWrapper($data[0], $data[1]);
}
}