function hook_taxonomy_term_update

Act on taxonomy terms when updated.

Modules implementing this hook can act on the term object when updated.

Parameters

Drupal\taxonomy\Term $term: A taxonomy term entity.

Related topics

3 functions implement hook_taxonomy_term_update()

File

drupal/core/modules/taxonomy/taxonomy.api.php, line 180
Hooks provided by the Taxonomy module.

Code

function hook_taxonomy_term_update(Drupal\taxonomy\Term $term) {
  hook_taxonomy_term_delete($term);
  if (!empty($term->synonyms)) {
    foreach (explode("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
      if ($synonym) {
        db_insert('taxonomy_term_synonym')
          ->fields(array(
          'tid' => $term->tid,
          'name' => rtrim($synonym),
        ))
          ->execute();
      }
    }
  }
}