protected function DatabaseStorageControllerNG::invokeHook

Overrides DatabaseStorageController::invokeHook().

Invokes field API attachers in compatibility mode and disables it afterwards.

Overrides DatabaseStorageController::invokeHook

1 call to DatabaseStorageControllerNG::invokeHook()
DatabaseStorageControllerNG::save in drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
Overrides DatabaseStorageController::save().

File

drupal/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php, line 276
Definition of Drupal\Core\Entity\DatabaseStorageControllerNG.

Class

DatabaseStorageControllerNG
Implements Field API specific enhancements to the DatabaseStorageController 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)) {
    $entity
      ->setCompatibilityMode(TRUE);
    $function($this->entityType, $entity);
    $entity
      ->setCompatibilityMode(FALSE);
  }

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

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