function EntityStorageBase::invokeHook

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::invokeHook()
  2. 10 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::invokeHook()
  3. 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.

5 calls to EntityStorageBase::invokeHook()
ContentEntityStorageBase::invokeHook in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Invokes a hook on behalf of the entity.
EntityStorageBase::create in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Constructs a new entity object, without permanently saving it.
EntityStorageBase::delete in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Deletes permanently saved entities.
EntityStorageBase::doPostSave in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Performs post save entity processing.
EntityStorageBase::doPreSave in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Performs presave entity processing.
2 methods override EntityStorageBase::invokeHook()
ConfigEntityStorage::invokeHook in core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
Invokes a hook on behalf of the entity.
ContentEntityStorageBase::invokeHook in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Invokes a hook on behalf of the entity.

File

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

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.