function _makemeeting_clear_referencing_fields in Make Meeting Scheduler 7.2
Get all fields referencing a given bundle.
Parameters
$entity_type: The entity type of the bundle.
$bundle: The referenced bundle.
Return value
array An array of field names being able to reference the given bundle.
1 call to _makemeeting_clear_referencing_fields()
- _makemeeting_clear_referencing_entity_cache in ./
makemeeting.module - Invalidate referencing entities caches.
File
- ./
makemeeting.module, line 274 - Hooks and field implementations
Code
function _makemeeting_clear_referencing_fields($entity_type, $bundle) {
$static =& drupal_static(__FUNCTION__, array());
// Use a static temporary cache to avoid using too mush resources.
if (array_key_exists($entity_type, $static) && array_key_exists($bundle, $static[$entity_type])) {
return $static[$entity_type][$bundle];
}
$fields = field_info_fields();
$static[$entity_type][$bundle] = array();
foreach ($fields as $field_name => $field) {
// Check if the field is an entityreference field.
if ($field['type'] != 'entityreference') {
continue;
}
// Check if the entity_type match the target_type of the field.
if ($field['settings']['target_type'] != $entity_type) {
continue;
}
// If the field is using the base handler check if the bundle is allowed.
if ($field['settings']['handler'] == 'base' && !in_array($bundle, $field['settings']['handler_settings']['target_bundles'])) {
continue;
}
$static[$entity_type][$bundle][] = $field_name;
}
return $static[$entity_type][$bundle];
}