function NavigationThemeHooks::preprocessTopBar

Prepares variables for navigation top bar template.

Default template: top-bar.html.twig

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties and children of the top bar.

File

core/modules/navigation/src/Hook/NavigationThemeHooks.php, line 65

Class

NavigationThemeHooks
Theme hooks for navigation.

Namespace

Drupal\navigation\Hook

Code

public function preprocessTopBar(array &$variables) : void {
  $element = $variables['element'];
  foreach (TopBarRegion::cases() as $region) {
    $variables[$region->value] = $element[$region->value] ?? NULL;
  }
}

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