You are here

public function DumperPrefixCollection::mergeSlashNodes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Matcher/Dumper/DumperPrefixCollection.php \Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection::mergeSlashNodes()

Merges nodes whose prefix ends with a slash.

Children of a node whose prefix ends with a slash are moved to the parent node

File

vendor/symfony/routing/Matcher/Dumper/DumperPrefixCollection.php, line 88

Class

DumperPrefixCollection
Prefix tree of routes preserving routes order.

Namespace

Symfony\Component\Routing\Matcher\Dumper

Code

public function mergeSlashNodes() {
  $children = array();
  foreach ($this as $child) {
    if ($child instanceof self) {
      $child
        ->mergeSlashNodes();
      if ('/' === substr($child->prefix, -1)) {
        $children = array_merge($children, $child
          ->all());
      }
      else {
        $children[] = $child;
      }
    }
    else {
      $children[] = $child;
    }
  }
  $this
    ->setAll($children);
}