Load disabled items in a menu I load my main menu programmatically with the following code :

    $menuTree = \Drupal::menuTree();
    $menuTreeParameters = $menuTree-&gt;getCurrentRouteMenuTreeParameters($name);
    $menuTreeParameters
        -&gt;setMinDepth($minLevel)
        -&gt;setMaxDepth($maxLevel);

    $tree = $menuTree-&gt;load($name, $menuTreeParameters);
    $tree = $menuTree-&gt;transform($tree, $this-&gt;getDefaultManipulators());

    return render($menuTree-&gt;build($tree));


I would like to get all my menu items, included thoses which are disabled. When I inspect $tree variable, I have all my menu items.

I don't know why but after the call to the build method, I get only my enabled items.
Check this line in buildItems() which is called by $menuTree-&gt;build($tree), in \Drupal\Core\Menu\MenuLinkTree.php:

  // Generally we only deal with visible links, but just in case.
  if (!$link-&gt;isEnabled()) {
    continue;
  }


It's designed to exclude links that are not enabled. I played around with something like this to get them all showing:

foreach ($tree as $id =&gt; $treeItem) {
    // Get the link definition.
    $definition = $tree[$id]-&gt;link-&gt;getPluginDefinition();

    // Skip links that are already enabled.
    if ($definition['enabled'] == 1) {
        continue;
    }

    // Change definition and enable link.
    $definition['enabled'] = 1;

    // Recreate the link.
    // I'm not 100% sure about the correctness of this part. 
    // This is my first time playing with this stuff. Hopefully someone can fill in this blank.
    $pluginContainer = \Drupal::getContainer();
    $conf = [];
    $newLink = \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::create($pluginContainer, $conf, $id, $definition);
    $tree[$id]-&gt;link = $newLink;
}