function field_collection_host_entity_types in Field collection 7
Entity types that serve as host for field collections.
Return value
array The list of entities as provided by entity_get_info(), filtered by field collection usage.
2 calls to field_collection_host_entity_types()
- field_collection_tokens in ./
field_collection.tokens.inc - Implements hook_tokens().
- field_collection_token_info in ./
field_collection.tokens.inc - Implements hook_token_info().
File
- ./
field_collection.tokens.inc, line 133 - Provides host entity tokens for field_collection.module.
Code
function field_collection_host_entity_types() {
$host_entity_types =& drupal_static(__FUNCTION__, FALSE);
if ($host_entity_types === FALSE) {
$host_entity_types = array();
if (function_exists('entity_get_info')) {
$entity_types = entity_get_info();
}
// Look for all field instances, filter them by type == 'field_collection'
// and map the entity type it's connected to to the returned list.
foreach (field_info_field_map() as $field_instance) {
if ($field_instance['type'] == 'field_collection') {
foreach (array_keys($field_instance['bundles']) as $entity_type) {
if (!isset($host_entity_types[$entity_type])) {
// No need to test for existence in $entity_types. If it's not there
// your site is broken.
$host_entity_types[$entity_type] = $entity_types[$entity_type];
}
}
}
}
}
return $host_entity_types;
}