function Vocabulary::preDelete
Same name in other branches
- 8.9.x core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary::preDelete()
- 10 core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary::preDelete()
- 11.x core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary::preDelete()
Overrides ConfigEntityBase::preDelete
File
-
core/
modules/ taxonomy/ src/ Entity/ Vocabulary.php, line 109
Class
- Vocabulary
- Defines the taxonomy vocabulary entity.
Namespace
Drupal\taxonomy\EntityCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.