function MenuLinkTree::transform

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Menu/MenuLinkTree.php \Drupal\Core\Menu\MenuLinkTree::transform()
  2. 10 core/lib/Drupal/Core/Menu/MenuLinkTree.php \Drupal\Core\Menu\MenuLinkTree::transform()
  3. 11.x core/lib/Drupal/Core/Menu/MenuLinkTree.php \Drupal\Core\Menu\MenuLinkTree::transform()

Overrides MenuLinkTreeInterface::transform

File

core/lib/Drupal/Core/Menu/MenuLinkTree.php, line 138

Class

MenuLinkTree
Implements the loading, transforming and rendering of menu link trees.

Namespace

Drupal\Core\Menu

Code

public function transform(array $tree, array $manipulators) {
    foreach ($manipulators as $manipulator) {
        $callable = $manipulator['callable'];
        $callable = $this->controllerResolver
            ->getControllerFromDefinition($callable);
        // Prepare the arguments for the menu tree manipulator callable; the first
        // argument is always the menu link tree.
        if (isset($manipulator['args'])) {
            array_unshift($manipulator['args'], $tree);
            $tree = call_user_func_array($callable, $manipulator['args']);
        }
        else {
            $tree = call_user_func($callable, $tree);
        }
    }
    return $tree;
}

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