You are here

function claro_preprocess_menu_local_tasks in Drupal 9

Same name and namespace in other branches
  1. 8 core/themes/claro/claro.theme \claro_preprocess_menu_local_tasks()

Implements hook_preprocess_HOOK() for menu-local-tasks templates.

Use preprocess hook to set #attached to child elements because they will be processed by Twig and drupal_render will be invoked.

File

core/themes/claro/claro.theme, line 49
Functions to support theming in the Claro theme.

Code

function claro_preprocess_menu_local_tasks(&$variables) {
  if (!empty($variables['primary'])) {
    $variables['primary']['#attached'] = [
      'library' => [
        'claro/drupal.nav-tabs',
      ],
    ];
  }
  elseif (!empty($variables['secondary'])) {
    $variables['secondary']['#attached'] = [
      'library' => [
        'claro/drupal.nav-tabs',
      ],
    ];
  }
  foreach (Element::children($variables['primary']) as $key) {
    $variables['primary'][$key]['#level'] = 'primary';
  }
  foreach (Element::children($variables['secondary']) as $key) {
    $variables['secondary'][$key]['#level'] = 'secondary';
  }
}