function MenuTreeStorage::doCollectRoutesAndDefinitions

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::doCollectRoutesAndDefinitions()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::doCollectRoutesAndDefinitions()
  3. 11.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::doCollectRoutesAndDefinitions()

Collects all the route names and definitions.

Parameters

array $tree: A menu link tree from MenuTreeStorage::doBuildTreeData()

array $definitions: The collected definitions which are populated by reference.

Return value

array The collected route names.

1 call to MenuTreeStorage::doCollectRoutesAndDefinitions()
MenuTreeStorage::collectRoutesAndDefinitions in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Traverses the menu tree and collects all the route names and definitions.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 980

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function doCollectRoutesAndDefinitions(array $tree, array &$definitions) {
    $route_names = [];
    foreach (array_keys($tree) as $id) {
        $definitions[$id] = $this->definitions[$id];
        if (!empty($definitions[$id]['route_name'])) {
            $route_names[$definitions[$id]['route_name']] = $definitions[$id]['route_name'];
        }
        if ($tree[$id]['subtree']) {
            $route_names += $this->doCollectRoutesAndDefinitions($tree[$id]['subtree'], $definitions);
        }
    }
    return $route_names;
}

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