How can I activate a custom Menu Tree Manipulator for all menus

by Philipp Zedler   Last Updated July 17, 2017 10:07 AM

I've created a custom tree manipulator and provided it as the service mymodule.tree_manipulators:mark_deepest_level.

I can call the service and use the manipulator for a given menu in my PHP code. This works.

Now, I would like to use my tree manipulator for all menus. I thought, this should work:

function mytheme_menu_links_discovered_alter(&$links) {
  $menu_tree = \Drupal::menuTree();
  $manipulators = array(
    array('callable' => 'mymodule.tree_manipulators:mark_deepest_level'),
  );
  $links = $menu_tree->transform($links, $manipulators);
}

But it has no effect at all. Am I using the wrong hook? Where is my error?



Related Questions


Webservice endpoint with hook_services_resources()

Updated April 13, 2015 20:03 PM

Edit account menu item in user menu

Updated May 03, 2017 12:07 PM


Access to menu in drupal

Updated May 29, 2017 11:07 AM