function hook_entity_load
Same name in other branches
- 7.x modules/system/system.api.php \hook_entity_load()
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_load()
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_load()
- 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_load()
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
Related topics
2 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 core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ entity_crud_hook_test.module - Implements hook_entity_load().
- views_entity_test_entity_load in core/
modules/ views/ tests/ modules/ views_entity_test/ views_entity_test.module - Implements hook_entity_load().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1075
Code
function hook_entity_load(array $entities, $entity_type_id) {
foreach ($entities as $entity) {
$entity->foo = mymodule_add_something($entity);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.