Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Vocabulary.php

function Vocabulary::preDelete

Overrides ConfigEntityBase::preDelete

File

core/modules/taxonomy/src/Entity/Vocabulary.php, line 128

Class

Vocabulary
Defines the taxonomy vocabulary entity.

Namespace

Drupal\taxonomy\Entity

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal