public function DumperPrefixCollection::addPrefixRoute in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/routing/Matcher/Dumper/DumperPrefixCollection.php \Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection::addPrefixRoute()
Adds a route in the tree.
Parameters
DumperRoute $route The route:
Return value
DumperPrefixCollection The node the route was added to
Throws
\LogicException
File
- vendor/
symfony/ routing/ Matcher/ Dumper/ DumperPrefixCollection.php, line 57
Class
- DumperPrefixCollection
- Prefix tree of routes preserving routes order.
Namespace
Symfony\Component\Routing\Matcher\DumperCode
public function addPrefixRoute(DumperRoute $route) {
$prefix = $route
->getRoute()
->compile()
->getStaticPrefix();
for ($collection = $this; null !== $collection; $collection = $collection
->getParent()) {
// Same prefix, add to current leave
if ($collection->prefix === $prefix) {
$collection
->add($route);
return $collection;
}
// Prefix starts with route's prefix
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
$child = new self();
$child
->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1));
$collection
->add($child);
return $child
->addPrefixRoute($route);
}
}
// Reached only if the root has a non empty prefix
throw new \LogicException('The collection root must not have a prefix');
}