W3cubDocs

/Drupal 8

protected function ContentEntityStorageBase::invokeHook

protected ContentEntityStorageBase::invokeHook($hook, EntityInterface $entity)

Invokes a hook on behalf of the entity.

Parameters

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

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

Overrides EntityStorageBase::invokeHook

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 401

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

protected function invokeHook($hook, EntityInterface $entity) {
  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */

  switch ($hook) {
    case 'presave':
      $this->invokeFieldMethod('preSave', $entity);
      break;

    case 'insert':
      $this->invokeFieldPostSave($entity, FALSE);
      break;

    case 'update':
      $this->invokeFieldPostSave($entity, TRUE);
      break;
  }

  parent::invokeHook($hook, $entity);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityStorageBase.php/function/ContentEntityStorageBase::invokeHook/8.1.x