function path_taxonomy_term_insert

Implements hook_taxonomy_term_insert().

File

drupal/core/modules/path/path.module, line 272
Enables users to rename URLs.

Code

function path_taxonomy_term_insert(Term $term) {
  if (isset($term->path)) {
    $path = $term->path;
    $path['alias'] = trim($path['alias']);

    // Only save a non-empty alias.
    if (!empty($path['alias'])) {

      // Ensure fields for programmatic executions.
      $path['source'] = 'taxonomy/term/' . $term->tid;
      $path['langcode'] = LANGUAGE_NOT_SPECIFIED;
      drupal_container()
        ->get('path.crud')
        ->save($path['source'], $path['alias'], $path['langcode']);
    }
  }
}