function DevelLazyBuilders::processTree

Adds toolbar-specific attributes to the menu link tree.

Parameters

\Drupal\Core\Menu\MenuLinkTreeElement[] $tree: The menu link tree to manipulate.

Return value

\Drupal\Core\Menu\MenuLinkTreeElement[] The manipulated menu link tree.

1 call to DevelLazyBuilders::processTree()
DevelLazyBuilders::renderMenu in src/DevelLazyBuilders.php
Lazy builder callback for the devel menu toolbar.

File

src/DevelLazyBuilders.php, line 91

Class

DevelLazyBuilders
Lazy builders for the devel module.

Namespace

Drupal\devel

Code

public function processTree(array $tree) : array {
    $visible_items = $this->config
        ->get('toolbar_items') ?: [];
    foreach ($tree as $element) {
        $plugin_id = $element->link
            ->getPluginId();
        if (!in_array($plugin_id, $visible_items)) {
            // Add a class that allow to hide the non prioritized menu items when
            // the toolbar has horizontal orientation.
            $element->options['attributes']['class'][] = 'toolbar-horizontal-item-hidden';
        }
    }
    return $tree;
}