function UmamiHooks::preprocessLinks
Same name and namespace in other branches
- main core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php \Drupal\umami\Hook\UmamiHooks::preprocessLinks()
Implements hook_preprocess_HOOK() for links.
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
Attributes
#[Hook('preprocess_links')]
File
-
core/
profiles/ demo_umami/ themes/ umami/ src/ Hook/ UmamiHooks.php, line 197
Class
- UmamiHooks
- Hook implementations for umami.
Namespace
Drupal\umami\HookCode
public function preprocessLinks(&$variables) : void {
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.