hook_entity_load

hook_entity_load(array $entities, $entity_type_id)

Act on entities when loaded.

This is a generic load hook called for all entity types loaded via the entity API.

hook_entity_storage_load() should be used to load additional data for content entities.

Parameters

\Drupal\Core\Entity\EntityInterface[] $entities: The entities keyed by entity ID.

string $entity_type_id: The type of entities being loaded (i.e. node, user, comment).

See also

hook_ENTITY_TYPE_load()

Related topics

Entity CRUD, editing, and view hooks
Hooks used in various entity operations.
Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 837
Hooks and documentation related to entities.

Code

function hook_entity_load(array $entities, $entity_type_id) {
  foreach ($entities as $entity) {
    $entity->foo = mymodule_add_something($entity);
  }
}
doc_Drupal
2016-10-29 09:18:00
Comments
Leave a Comment

Please login to continue.