protected function DatabaseStorageController::invokeHook

Invokes a hook on behalf of the entity.

Parameters

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

$entity: The entity object.

2 methods override DatabaseStorageController::invokeHook()
DatabaseStorageControllerNG::invokeHook in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::invokeHook().
NodeStorageController::invokeHook in drupal/core/modules/node/lib/Drupal/node/NodeStorageController.php
Overrides Drupal\Core\Entity\DatabaseStorageController::invokeHook().

File

drupal/core/lib/Drupal/Core/Entity/DatabaseStorageController.php, line 634
Definition of Drupal\Core\Entity\DatabaseStorageController.

Class

DatabaseStorageController
Defines a base entity controller class.

Namespace

Drupal\Core\Entity

Code

protected function invokeHook($hook, EntityInterface $entity) {
  $function = 'field_attach_' . $hook;

  // @todo: field_attach_delete_revision() is named the wrong way round,
  // consider renaming it.
  if ($function == 'field_attach_revision_delete') {
    $function = 'field_attach_delete_revision';
  }
  if (!empty($this->entityInfo['fieldable']) && function_exists($function)) {
    $function($this->entityType, $entity);
  }

  // Invoke the hook.
  module_invoke_all($this->entityType . '_' . $hook, $entity);

  // Invoke the respective entity-level hook.
  module_invoke_all('entity_' . $hook, $entity, $this->entityType);
}