You are here

function field_entity_dependencies in Entity Dependency API 7

Implements hook_entity_dependencies().

Related topics

File

./entity_dependency.core.inc, line 79
Contains hook implementations for all relevant core module.

Code

function field_entity_dependencies($entity, $entity_type) {
  $dependencies = array();
  list(, , $bundle_name) = entity_extract_ids($entity_type, $entity);
  $instances = field_info_instances($entity_type, $bundle_name);
  foreach ($instances as $field_name => $instance) {
    $field = field_info_field($field_name);
    foreach ($entity->{$field_name} as $langcode => $items) {
      $field_dependencies = module_invoke($field['module'], 'field_entity_dependencies', $entity_type, $entity, $field, $instance, $langcode, $items);

      // Let other modules alter dependencies for this field.
      drupal_alter('field_entity_dependencies', $field_dependencies, $entity_type, $entity, $field, $instance, $langcode, $items);
      if (!empty($field_dependencies)) {
        $dependencies = array_merge_recursive($dependencies, $field_dependencies);
      }
    }
  }
  return $dependencies;
}