function NavigationRenderer::buildTopBar

Build the top bar for content entity pages.

Parameters

array $page_top: A renderable array representing the top of the page.

See also

navigation_page_top()

hook_page_top()

File

core/modules/navigation/src/NavigationRenderer.php, line 206

Class

NavigationRenderer
Handle rendering for different pieces of the navigation.

Namespace

Drupal\navigation

Code

public function buildTopBar(array &$page_top) : void {
  $page_top['top_bar']['#cache']['contexts'][] = 'user.permissions';
  if ($this->currentUser
    ->hasPermission('access navigation')) {
    $page_top['top_bar'] = [
      '#cache' => [
        'keys' => [
          'navigation',
          'top_bar',
        ],
        'max-age' => CacheBackendInterface::CACHE_PERMANENT,
      ],
      '#lazy_builder' => [
        'navigation.renderer:doBuildTopBar',
        [],
      ],
      '#create_placeholder' => TRUE,
    ];
  }
}

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