protected function UserStorageController::invokeHook

Overrides DatabaseStorageController::invokeHook().

Invokes field API attachers with a BC entity.

Overrides DatabaseStorageControllerNG::invokeHook

File

drupal/core/modules/user/lib/Drupal/user/UserStorageController.php, line 234
Definition of Drupal\user\UserStorageController.

Class

UserStorageController
Controller class for users.

Namespace

Drupal\user

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($entity
      ->getBCEntity());
  }

  // Invoke the hook.
  \Drupal::moduleHandler()
    ->invokeAll($this->entityType . '_' . $hook, array(
    $entity
      ->getBCEntity(),
  ));

  // Invoke the respective entity-level hook.
  \Drupal::moduleHandler()
    ->invokeAll('entity_' . $hook, array(
    $entity
      ->getBCEntity(),
    $this->entityType,
  ));
}