You are here

function hook_entity_dependencies in Entity Dependency API 7

Define dependencies to an entity.

Return an array that defines dependencies to the $entity. The entity_dependency_add() function is a good helper function.

Parameters

$entity: The entity to return dependencies for.

$entity_type: The entity type of the $entity.

Return value

array The dependencies should be returned as defined below, where the keys are the entity type of the returned dependencies. @code $dependencies = array( 'node' => array(

See also

entity_dependency_add()

13 functions implement hook_entity_dependencies()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

comment_entity_dependencies in ./entity_dependency.core.inc
Implements hook_entity_dependenies().
entityreference_field_entity_dependencies in ./entity_dependency.core.inc
Implements hook_field_entity_dependencies().
field_collection_field_entity_dependencies in ./entity_dependency.core.inc
Implements hook_field_entity_dependencies().
field_entity_dependencies in ./entity_dependency.core.inc
Implements hook_entity_dependencies().
file_entity_dependencies in ./entity_dependency.core.inc
Implements hook_entity_dependenies().

... See full list

1 invocation of hook_entity_dependencies()
EntityDependencyIterator::hasChildren in ./EntityDependencyIterator.inc
Returns TRUE if an iterator can be created for the current item in the entities array.

File

./entity_dependency.api.php, line 41
Hooks provided by the Entity Dependency module.

Code

function hook_entity_dependencies($entity, $entity_type) {
  if ($entity_type == 'node') {
    $dependencies = array();

    // The node has a 'user' dependency through the 'uid' and
    // 'revision_uid' properties.
    entity_dependency_add($dependencies, $entity, 'user', array(
      'uid',
      'revision_uid',
    ));

    // The node has a 'node' dependency through the 'tnid' property.
    entity_dependency_add($dependencies, $entity, 'node', 'tnid');
    return $dependencies;
  }
}