You are here

protected function MenuSelectTreeBuilder::generateLink in Menu Select 8

Same name and namespace in other branches
  1. 2.0.x src/MenuSelectTreeBuilder.php \Drupal\menu_select\MenuSelectTreeBuilder::generateLink()

Generates a link for an item in the menu tree.

Parameters

\Drupal\Core\Menu\MenuLinkInterface $link: The menu link.

string $menu_key: The menu key of the link.

Return value

array The renderable array for a link.

1 call to MenuSelectTreeBuilder::generateLink()
MenuSelectTreeBuilder::buildNestedMenu in src/MenuSelectTreeBuilder.php
Function to generate an array of the full menu.

File

src/MenuSelectTreeBuilder.php, line 130

Class

MenuSelectTreeBuilder
A service for building out the menu trees used in menu select.

Namespace

Drupal\menu_select

Code

protected function generateLink(MenuLinkInterface $link, $menu_key) {
  return [
    // Use a string of markup for the link, since it is much faster than using
    // renderable arrays and link objects for large menus.
    '#markup' => new FormattableMarkup('<a data-mkey="@mkey" class="menu-select-menu-link js-menu-select-menu-link" href="#menu-select-parent-menu">@title</a>', [
      '@title' => $link
        ->getTitle(),
      '@mkey' => $menu_key,
    ]),
  ];
}