function TaxonomyHooks::taxonomyTermDelete

Same name and namespace in other branches
  1. 11.x core/modules/taxonomy/src/Hook/TaxonomyHooks.php \Drupal\taxonomy\Hook\TaxonomyHooks::taxonomyTermDelete()

Implements hook_ENTITY_TYPE_delete() for taxonomy_term entities.

Attributes

#[Hook('taxonomy_term_delete')]

File

core/modules/taxonomy/src/Hook/TaxonomyHooks.php, line 169

Class

TaxonomyHooks
Hook implementations for taxonomy.

Namespace

Drupal\taxonomy\Hook

Code

public function taxonomyTermDelete(Term $term) : void {
  if (\Drupal::config('taxonomy.settings')->get('maintain_index_table')) {
    // Clean up the {taxonomy_index} table when terms are deleted.
    \Drupal::database()->delete('taxonomy_index')
      ->condition('tid', $term->id())
      ->execute();
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.