public function Menu::convertLinksToMenuLinks in Helper 8
Convert a link field to an array of menu links.
Parameters
\Drupal\Core\Link[] $links: The links to convert.
Return value
array The menu link items, ready for rendering in a menu.
1 call to Menu::convertLinksToMenuLinks()
- Menu::buildLinksAsMenu in src/
Menu.php - Builds a render array of a set of links like a menu.
File
- src/
Menu.php, line 163
Class
- Menu
- Provides helpers working with menus and menu links.
Namespace
Drupal\helperCode
public function convertLinksToMenuLinks(array $links) {
$menu_links = [];
// Generate a menu-link-style key for each link.
$key_prefix = 'helper_link:';
foreach ($links as $delta => $link) {
$menu_link = $this
->convertLinkToMenuLink($link);
$menu_links[$key_prefix . md5(serialize($menu_link))] = $menu_link;
}
return $menu_links;
}