By fgm on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
The entity hooks acting on individual entities used to receive a $type parameter enabling Drupal to obtain the entity information. Now that entities are classed objects implementing EntityInterface, this is no longer necessary, because implementations can use the EntityInterface::entityType() method to obtain that information if needed.
In addition, type hinting is now required from implementations of these hooks.
Affected hooks are:
| Before | After |
|---|---|
hook_entity_presave($entity, $type) |
hook_entity_presave(Drupal\entity\EntityInterface $entity) |
hook_entity_insert($entity, $type) |
hook_entity_insert(Drupal\entity\EntityInterface $entity) |
hook_entity_update($entity, $type) |
hook_entity_update(Drupal\entity\EntityInterface $entity) |
hook_entity_predelete($entity, $type) |
hook_entity_predelete(Drupal\entity\EntityInterface $entity) |
hook_entity_delete($entity, $type) |
hook_entity_delete(Drupal\entity\EntityInterface $entity) |
hook_entity_view($entity, $type, $view_mode, $langcode) |
hook_entity_view(Drupal\entity\EntityInterface $entity, $view_mode, $langcode) |
hook_entity_view_alter(&$build, $type) |
hook_entity_view_alter(&$build, Drupal\entity\EntityInterface $entity) |
Hooks operating on multiple entities (hook_entity_load(), hook_entity_prepare_view()) are not affected by this change.
Impacts:
Module developers