getToplevelTids example

return $this->description;
  }

  /** * {@inheritdoc} */
  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);
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    // Reset caches.     $storage->resetCache(array_keys($entities));

    
Home | Imprint | This part of the site doesn't use cookies.