public function RouteCollection::addPrefix

Adds a prefix to the path of all child routes.

@api

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:

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php, line 149

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