You are here

protected function MenuTreeStorage::doCollectRoutesAndDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 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 1001

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;
}