private function PhpMatcherDumper::buildPrefixTree

Organizes the routes into a prefix tree.

Routes order is preserved such that traversing the tree will traverse the routes in the origin order.

Parameters

DumperCollection $collection A collection of routes:

Return value

DumperPrefixCollection

1 call to PhpMatcherDumper::buildPrefixTree()
PhpMatcherDumper::compileRoutes in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
Generates PHP code to match a RouteCollection with all its routes.

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php, line 365

Class

PhpMatcherDumper
PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes.

Namespace

Symfony\Component\Routing\Matcher\Dumper

Code

private function buildPrefixTree(DumperCollection $collection) {
  $tree = new DumperPrefixCollection();
  $current = $tree;
  foreach ($collection as $route) {
    $current = $current
      ->addPrefixRoute($route);
  }
  $tree
    ->mergeSlashNodes();
  return $tree;
}