function claro_preprocess_links
Same name in other branches
- 9 core/themes/claro/claro.theme \claro_preprocess_links()
- 8.9.x core/themes/claro/claro.theme \claro_preprocess_links()
- 10 core/themes/claro/claro.theme \claro_preprocess_links()
Implements hook_preprocess_HOOK() for links.
File
-
core/
themes/ claro/ claro.theme, line 528
Code
function claro_preprocess_links(&$variables) {
foreach ($variables['links'] as $links_item) {
if (!empty($links_item['link']) && !empty($links_item['link']['#url']) && $links_item['link']['#url'] instanceof Url) {
if ($links_item['link']['#url']->isRouted()) {
switch ($links_item['link']['#url']->getRouteName()) {
case 'system.theme_settings_theme':
$links_item['link'] = _claro_convert_link_to_action_link($links_item['link'], 'cog', 'small');
break;
case 'system.theme_uninstall':
$links_item['link'] = _claro_convert_link_to_action_link($links_item['link'], 'ex', 'small');
break;
case 'system.theme_set_default':
$links_item['link'] = _claro_convert_link_to_action_link($links_item['link'], 'checkmark', 'small');
break;
case 'system.theme_install':
$links_item['link'] = _claro_convert_link_to_action_link($links_item['link'], 'plus', 'small');
break;
}
}
}
}
// This makes it so array keys of #links items are added as a class. This
// functionality was removed in Drupal 8.1, but still necessary in some
// instances.
// @todo Remove in https://drupal.org/node/3120962
if (!empty($variables['links'])) {
foreach ($variables['links'] as $key => $value) {
if (!is_numeric($key)) {
$class = Html::getClass($key);
$variables['links'][$key]['attributes']->addClass($class);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.