function language_hierarchy_preprocess_taxonomy_term in Language Hierarchy 8
Same name and namespace in other branches
- 2.x language_hierarchy.module \language_hierarchy_preprocess_taxonomy_term()
Implements hook_preprocess_taxonomy_term().
File
- ./language_hierarchy.module, line 488 
- Add sublanguage handling functionality to Drupal.
Code
function language_hierarchy_preprocess_taxonomy_term(&$variables) {
  if (!empty($variables['url'])) {
    /** @var \Drupal\taxonomy\TermInterface $term */
    $term = $variables['term'];
    $url = $variables['url'];
    if (is_string($url)) {
      $url_obj = $term
        ->toUrl();
      if ($url_obj
        ->toString() === $url) {
        $url = $url_obj;
      }
    }
    if ($url instanceof Url) {
      $variables['url'] = language_hierarchy_fix_url_from_fallback($url, $term)
        ->toString();
    }
  }
}