public static function Vocabulary::preDelete in Drupal 8
Same name and namespace in other branches
- 9 core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary::preDelete()
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides ConfigEntityBase::preDelete
File
- core/
modules/ taxonomy/ src/ Entity/ Vocabulary.php, line 124
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);
}