You are here

public function EntityHook::onEntityRevisionDelete in Editor Notes 8

Delete on Editor Note revisions on entity revision delete.

Parameters

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

See also

editor_note_entity_revision_delete

File

src/Hook/EntityHook.php, line 145

Class

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

Namespace

Drupal\editor_note\Hook

Code

public function onEntityRevisionDelete(EntityInterface $entity) {
  $entities = $this->entityTypeManager
    ->getStorage('editor_note')
    ->loadByProperties([
    'bundle' => $entity
      ->bundle(),
    'entity_id' => $entity
      ->id(),
    'revision_id' => $entity
      ->getOriginalId(),
  ]);
  foreach ($entities as $entity) {
    $entity
      ->delete();
  }
}