function LinksetController::loadMenuTree

Same name in other branches
  1. 10 core/modules/system/src/Controller/LinksetController.php \Drupal\system\Controller\LinksetController::loadMenuTree()

Loads a menu tree.

Parameters

\Drupal\system\MenuInterface $menu: A menu for which a tree should be loaded.

Return value

\Drupal\Core\Menu\MenuLinkTreeElement[] A menu link tree.

1 call to LinksetController::loadMenuTree()
LinksetController::process in core/modules/system/src/Controller/LinksetController.php
Serve linkset requests.

File

core/modules/system/src/Controller/LinksetController.php, line 269

Class

LinksetController
Linkset controller.

Namespace

Drupal\system\Controller

Code

protected function loadMenuTree(MenuInterface $menu) : array {
    $parameters = new MenuTreeParameters();
    $parameters->onlyEnabledLinks();
    $parameters->setMinDepth(0);
    $tree = $this->menuTree
        ->load($menu->id(), $parameters);
    $manipulators = [
        [
            'callable' => 'menu.default_tree_manipulators:checkAccess',
        ],
        [
            'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
        ],
    ];
    return $this->menuTree
        ->transform($tree, $manipulators);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.