You are here

function seven_preprocess_links in Drupal 9

Implements template_preprocess_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

File

core/themes/seven/seven.theme, line 459
Functions to support theming in the Seven theme.

Code

function seven_preprocess_links(&$variables) {
  if (!empty($variables['links'])) {
    foreach ($variables['links'] as $key => $value) {
      if (!is_numeric($key)) {
        $class = Html::getClass($key);
        $variables['links'][$key]['attributes']
          ->addClass($class);
      }
    }
  }
}