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