You are here

public function Menu::buildLinksAsMenu in Helper 8

Builds a render array of a set of links like a menu.

Parameters

string $menu_name: The menu name (any value can be provided).

\Drupal\Core\Link[] $links: An array of links.

Return value

array The render array.

File

src/Menu.php, line 144

Class

Menu
Provides helpers working with menus and menu links.

Namespace

Drupal\helper

Code

public function buildLinksAsMenu($menu_name, array $links) {
  return [
    '#theme' => 'menu__' . strtr($menu_name, '-', '_'),
    '#menu_name' => $menu_name,
    '#items' => $this
      ->convertLinksToMenuLinks($links),
    // Make sure drupal_render() does not re-order the links.
    '#sorted' => TRUE,
  ];
}