Symfony\Component\Routing\RouteCollection::addPrefix PHP Method

addPrefix() public method

Adds a prefix to all routes in the current set.
public addPrefix ( string $prefix )
$prefix string An optional prefix to add before each pattern of the route collection
    public function addPrefix($prefix)
    {
        if (!$prefix) {
            return;
        }

        foreach ($this->all() as $route) {
            $route->setPattern($prefix.$route->getPattern());
        }
    }

Same methods

RouteCollection::addPrefix ( string $prefix, array $defaults = [], array $requirements = [], array $options = [] )

Usage Example

Example #1
0
 /**
  * Adds a route collection to the current set of routes (at the end of the current set).
  *
  * @param RouteCollection $collection A RouteCollection instance
  * @param string          $prefix     An optional prefix to add before each pattern of the route collection
  */
 public function addCollection(RouteCollection $collection, $prefix = '')
 {
     $collection->addPrefix($prefix);
     foreach ($collection->getResources() as $resource) {
         $this->addResource($resource);
     }
     $this->routes = array_merge($this->routes, $collection->all());
 }
All Usage Examples Of Symfony\Component\Routing\RouteCollection::addPrefix