You are here

public function EntityHook::onFieldDelete in Editor Notes 8

Delete Editor Note on field delete.

Parameters

\Drupal\field\Entity\FieldConfig $field: The field being purged.

See also

editor_note_field_purge_field

File

src/Hook/EntityHook.php, line 164

Class

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

Namespace

Drupal\editor_note\Hook

Code

public function onFieldDelete(FieldConfig $field) {
  $entities = $this->entityTypeManager
    ->getStorage('editor_note')
    ->loadByProperties([
    'bundle' => $field
      ->getTargetBundle(),
    'field_machine_name' => $field
      ->getName(),
  ]);
  foreach ($entities as $entity) {
    $entity
      ->delete();
  }
}