Can menuTree load a menu's items including children From what I understand I should be able to retrieve all the items in a menu using menuTree. However I only get one level/depth no matter what I try. 

My Menu Looks Like:


  Imported Content
  --Products
  ----A Child
  ------Grand Child
  --------Great Grandchild
  ------Grand Child 2
  ----Child 2
  --A Sibling
  Screenshot from Drupal: https://www.evernote.com/l/AAKdnwekb7BM87AFANo1z2XjCdEvR8HgDEI


This is my code:

$menu_name = 'imported-content-menu';
  $menu_tree = \Drupal::menuTree();
  $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
  $parameters->setMaxDepth(100);
  $parameters->setMinDepth(0);
  $tree = $menu_tree->load($menu_name, $parameters);  

When I inspect $tree, it is an array of two items "Products" and "A Sibling". 

I inspected these two items to see if there were nested items (the children) but there were not. 

The "Products" item has 'hasChildren' set to TRUE. But I don't see those children.
Within the typical route context ($menu_tree-&gt;getCurrentRouteMenuTreeParameters($menu_name)), subtree elements are loaded only, if the menu item is flagged as "Show as expanded" within the menu item settings.

To load the entire tree, you have to pass in a plain MenuTreeParameters object without the current route context:

use Drupal\Core\Menu\MenuTreeParameters;

$parameters = new MenuTreeParameters();

// Optionally limit to enabled items.
$parameters-&gt;onlyEnabledLinks();

// Optionally set active trail.
$menu_active_trail = \Drupal::service('menu.active_trail')-&gt;getActiveTrailIds($menu_name);
$parameters-&gt;setActiveTrail($menu_active_trail);

// Load the tree.
$tree = \Drupal::menuTree()-&gt;load($menu_name, $parameters);