Discovered via π± Configuration change data loss prevention functionality inconsistent, restrictive Active .
public static function preDelete(EntityStorageInterface $storage, array $entities) {
parent::preDelete($storage, $entities);
// Only load terms without a parent, child terms will get deleted too.
$term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$terms = $term_storage->loadMultiple($storage- >getToplevelTids(array_keys($entities)));
$term_storage->delete($terms);
}
When there are lots of terms, this is going to run out of memory.
Add the same kind of handling as node types:
Example is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the
Example content."
Eventually, we could add the option to delete all too, but that would have to be done in a queue/batch and should be implemented generically for all content entities.