function OliveroHooks::preprocessMenu

Same name and namespace in other branches
  1. main core/themes/olivero/src/Hook/OliveroHooks.php \Drupal\olivero\Hook\OliveroHooks::preprocessMenu()

Implements hook_preprocess_HOOK() for menu.

Attributes

#[Hook('preprocess_menu')]

File

core/themes/olivero/src/Hook/OliveroHooks.php, line 144

Class

OliveroHooks
Hook implementations for olivero.

Namespace

Drupal\olivero\Hook

Code

public function preprocessMenu(&$variables) : void {
  if (isset($variables['attributes']['region'])) {
    if ($variables['attributes']['region'] === 'sidebar') {
      $variables['attributes']['class'][] = 'menu--sidebar';
    }
    unset($variables['attributes']['region']);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.