Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TopBar.php

function TopBar::preRenderTopBar

Builds the TopBar as a structured array ready for rendering.

Since building the TopBar takes some time, it is done just prior to rendering to ensure that it is built only if it will be displayed.

Parameters

array $element: A renderable array.

Return value

array A renderable array.

See also

navigation_page_top()

File

core/modules/navigation/src/Element/TopBar.php, line 50

Class

TopBar
Provides a render element for the default Drupal toolbar.

Namespace

Drupal\navigation\Element

Code

public static function preRenderTopBar($element) : array {
    $top_bar_item_manager = static::topBarItemManager();
    // Group the items by region.
    foreach (TopBarRegion::cases() as $region) {
        $items = $top_bar_item_manager->getRenderedTopBarItemsByRegion($region);
        $element = array_merge($element, [
            $region->value => $items,
        ]);
    }
    return $element;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal