function EntityStorageBase::invokeHook

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::invokeHook()

Invokes a hook on behalf of the entity.

Parameters

string $hook: One of 'create', 'presave', 'insert', 'update', 'predelete', 'delete', or 'revision_delete'.

\Drupal\Core\Entity\EntityInterface $entity: The entity object.

File

core/lib/Drupal/Core/Entity/EntityStorageBase.php, line 247

Class

EntityStorageBase
A base entity storage class.

Namespace

Drupal\Core\Entity

Code

protected function invokeHook($hook, EntityInterface $entity) {
  // Invoke the hook.
  $this->moduleHandler()
    ->invokeAll($this->entityTypeId . '_' . $hook, [
    $entity,
  ]);
  // Invoke the respective entity-level hook.
  $this->moduleHandler()
    ->invokeAll('entity_' . $hook, [
    $entity,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.