I'm trying to display a menu in my module. I've used \Drupal::entityManager()->getStorage('menu')->load('oz-topbar-menu');
which allows me to get the title of the menu, the description, etc.
I obviously need the links of that menu, and I can't understand how to retrieve. From what I've read in the documentation I should probably use MenuLinkTreeInterface but I don't understand how to instantiate it.
I've tried \Drupal::menuTree()->load('oz-topbar-menu', $menu_parameters);
. With basic menu parameters it returns a humongous amount of information; I'm guessing it must be the entire menu tree of Drupal.
I tried playing with the parameters of MenuTreeParameters
(setTopLevelOnly
, setRoot('oz-topbar-menu')
) but it returns an empty array.
I've tried sending this as a MenuTreeParameters
object with \Drupal::menuTree()->getCurrentRouteMenuTreeParameters('oz-topbar-menu')
, but I still get a massive link tree.