You are here

public function RouteCollection::addPrefix in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/RouteCollection.php \Symfony\Component\Routing\RouteCollection::addPrefix()

Adds a prefix to the path of all child routes.

Parameters

string $prefix An optional prefix to add before each pattern of the route collection:

array $defaults An array of default values:

array $requirements An array of requirements:

1 method overrides RouteCollection::addPrefix()
ChainRouteCollection::addPrefix in vendor/symfony-cmf/routing/ChainRouteCollection.php
Adds a prefix to the path of all child routes.

File

vendor/symfony/routing/RouteCollection.php, line 141

Class

RouteCollection
A RouteCollection represents a set of Route instances.

Namespace

Symfony\Component\Routing

Code

public function addPrefix($prefix, array $defaults = array(), array $requirements = array()) {
  $prefix = trim(trim($prefix), '/');
  if ('' === $prefix) {
    return;
  }
  foreach ($this->routes as $route) {
    $route
      ->setPath('/' . $prefix . $route
      ->getPath());
    $route
      ->addDefaults($defaults);
    $route
      ->addRequirements($requirements);
  }
}