function hook_entity_load

Act on entities when loaded.

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

Parameters

array $entities: The entities keyed by entity ID.

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

Related topics

3 functions implement hook_entity_load()

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

entity_crud_hook_test_entity_load in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_entity_load().
rdf_entity_load in drupal/core/modules/rdf/rdf.module
Implements hook_entity_load().
translation_entity_entity_load in drupal/core/modules/translation_entity/translation_entity.module
Implements hook_entity_load().
3 invocations of hook_entity_load()
ConfigStorageController::attachLoad in drupal/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
Attaches data to entities upon loading.
DatabaseStorageController::attachLoad in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
Attaches data to entities upon loading.
DatabaseStorageControllerNG::attachLoad in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::attachLoad().

File

drupal/core/includes/entity.api.php, line 69
Hooks provided the Entity module.

Code

function hook_entity_load($entities, $entity_type) {
  foreach ($entities as $entity) {
    $entity->foo = mymodule_add_something($entity);
  }
}