function ShortcutLazyBuilder::lazyLinks

Same name and namespace in other branches
  1. 11.x core/modules/navigation/src/ShortcutLazyBuilder.php \Drupal\navigation\ShortcutLazyBuilder::lazyLinks()

The #lazy_builder callback; builds shortcut navigation links.

Parameters

string $label: (Optional) The links label. Defaults to "Shortcuts".

Return value

array A renderable array of shortcut links.

File

core/modules/navigation/src/ShortcutLazyBuilder.php, line 44

Class

ShortcutLazyBuilder
Lazy Builders for Navigation shortcuts links.

Namespace

Drupal\navigation

Code

public function lazyLinks(string $label = 'Shortcuts') {
  $shortcut_links = $this->shortcutLazyBuilder
    ->lazyLinks();
  if (empty($shortcut_links['shortcuts']['#links'])) {
    return [
      '#cache' => $shortcut_links['#cache'],
    ];
  }
  $shortcuts_items = [
    [
      'title' => $label,
      'class' => 'shortcuts',
      'below' => $shortcut_links['shortcuts']['#links'],
    ],
  ];
  return [
    '#title' => $label,
    '#theme' => 'navigation_menu',
    '#menu_name' => 'shortcuts',
    '#items' => $shortcuts_items,
    '#cache' => $shortcut_links['#cache'],
  ];
}

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