function DevelLazyBuilders::renderMenu

Lazy builder callback for the devel menu toolbar.

Return value

array The renderable array rapresentation of the devel menu.

File

src/DevelLazyBuilders.php, line 56

Class

DevelLazyBuilders
Lazy builders for the devel module.

Namespace

Drupal\devel

Code

public function renderMenu() : array {
    $parameters = new MenuTreeParameters();
    $parameters->onlyEnabledLinks()
        ->setTopLevelOnly();
    $tree = $this->menuLinkTree
        ->load('devel', $parameters);
    $manipulators = [
        [
            'callable' => 'menu.default_tree_manipulators:checkAccess',
        ],
        [
            'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
        ],
        [
            'callable' => function (array $tree) : array {
                return $this->processTree($tree);
            },
        ],
    ];
    $tree = $this->menuLinkTree
        ->transform($tree, $manipulators);
    $build = $this->menuLinkTree
        ->build($tree);
    $build['#attributes']['class'] = [
        'toolbar-menu',
    ];
    CacheableMetadata::createFromRenderArray($build)->addCacheableDependency($this->config)
        ->applyTo($build);
    return $build;
}