You are here

public function EntityHook::onUserDelete in Editor Notes 8

Delete Editor Note on user deletion.

Parameters

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

See also

editor_note_entity_user_delete

File

src/Hook/EntityHook.php, line 109

Class

EntityHook
Be aware of some entity hooks to perform actions on editor note.

Namespace

Drupal\editor_note\Hook

Code

public function onUserDelete(EntityInterface $entity) {
  $notes = $this->entityTypeManager
    ->getStorage('editor_note')
    ->loadByProperties([
    'uid' => $entity
      ->id(),
  ]);
  foreach ($notes as $note) {
    $note
      ->delete();
  }
}