function NavigationRenderer::getContentTop

Gets the content for content_top section.

Return value

array The content_top section content.

1 call to NavigationRenderer::getContentTop()
NavigationRenderer::doBuildNavigation in core/modules/navigation/src/NavigationRenderer.php
Pre-render callback for ::buildNavigation.

File

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

Class

NavigationRenderer
Handle rendering for different pieces of the navigation.

Namespace

Drupal\navigation

Code

protected function getContentTop() : array {
  $content_top = [
    '#theme' => 'navigation_content_top',
  ];
  $content_top_items = $this->moduleHandler
    ->invokeAll('navigation_content_top');
  $this->moduleHandler
    ->alter('navigation_content_top', $content_top_items);
  uasort($content_top_items, [
    SortArray::class,
    'sortByWeightElement',
  ]);
  // Filter out empty items, taking care to merge any cacheability metadata.
  $cacheability = new CacheableMetadata();
  $content_top_items = array_filter($content_top_items, function ($item) use (&$cacheability) {
    if (Element::isEmpty($item)) {
      $cacheability = $cacheability->merge(CacheableMetadata::createFromRenderArray($item));
      return FALSE;
    }
    return TRUE;
  });
  $cacheability->applyTo($content_top);
  $content_top['#items'] = $content_top_items;
  return $content_top;
}

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