Add a RouteCollectionBuilder.

@param string                 $prefix
@param RouteCollectionBuilder $builder
507939
public function mount($prefix, self $builder)
    {
        $builder->prefix = trim(trim($prefix), '/');
        $this->routes[] = $builder;
    }
1207347
private function createMap(RouteCollectionInterface $routes)
    {
        $i    = 0;
        $m    = [];
        $rpl  = sprintf(self::NGRP_RPLC, Ps::EXP_DELIM);
        $expr = [];
        $pfx  = 'r'.time();
        $expr['prefix'] = $pfx;

        foreach ($routes->all() as $name => $route) {
            foreach ($route->getMethods() as $method) {
                $m[$method][$name] = $route;
            }
        }

        foreach ($m as $mn => $rts) {
            $mn = strtolower($mn);
            $expr[$mn]['map'] = [];
            $regex = [];

            foreach ($rts as $rn => $rt) {
                $ctx      = $rt->getContext();
                $index    = $pfx.'_'.$this->replaceRouteName($rn, $i);
                $ctxRegex = preg_replace($rpl, '$1r'.(string)$i.'_$2>', $ctx->getRegex(true));
                $regex[]  = sprintf('(?P<%s>%s)', $index, $ctxRegex);
                $expr[$mn]['map'][$index] = [$i, $rn, 'r'.$i.'_'];
                $i++;
            }

            $i = 0;
            $expr[$mn]['regex'] = sprintf('%1$s(?:^'.join('|', $regex).')$%1$sx', Ps::EXP_DELIM);
        }

        return $expr;
    }
335251
private function remapParameters(ContainerBuilder $container, $prefix, array $config)
    {
        foreach ($config as $key => $value) {
            $container->setParameter(sprintf('%s.%s', $prefix, $key), $value);
        }
    }
1181886
public function populateCollection(RouteCollection $routes): RouteCollection
    {
        foreach ($this->items as $route) {
            if ($route instanceof self) {
                $route->populateCollection($routes);
            } else {
                $routes->add(...$route);
            }
        }

        return $routes;
    }
957087
public function addResource($resource, $prefix = null)
    {
        $this->resources[] = [$resource, $prefix, true];

        return $this;
    }
1330474
private function addRoute($name, array $route)
    {
        extract($this->defaults($route));

        $requirements[RouteCollectionBuilder::K_NAME] = $name;

        $this->builder->addRoute($method, $pattern, $handler, $requirements, $defaults);
    }
389209
public function addNamePrefix(string $prefix)
    {
        $prefixedRoutes = [];

        foreach ($this->routes as $name => $route) {
            $prefixedRoutes[$prefix.$name] = $route;
            if (null !== $name = $route->getDefault('_canonical_route')) {
                $route->setDefault('_canonical_route', $prefix.$name);
            }
        }

        $this->routes = $prefixedRoutes;
    }
841744
public function addPrefix($prefix, $paths)
    {
        if (!$prefix) {
            foreach ((array) $paths as $path) {
                $this->fallbackDirs[] = $path;
            }

            return;
        }
        if (isset($this->prefixes[$prefix])) {
            $this->prefixes[$prefix] = array_merge(
                $this->prefixes[$prefix],
                (array) $paths
            );
        } else {
            $this->prefixes[$prefix] = (array) $paths;
        }
    }
44310
protected function configureRoutes(\Sonata\AdminBundle\Route\RouteCollection $collection)
    {
        parent::configureRoutes($collection);

        $collection->clearExcept(array('create', 'edit', 'delete'));
    }
762939
protected function configureRoutes(RouteCollectionBuilder $routes)
    {
        foreach ($this->routes as $route) {
            is_array($route)
                ? $routes->add(
                    $route[0],
                    $route[1],
                    $route[2]
                )
                : $routes->import($route);
        }
    }
1027347
public function addRoute($methods, string $pattern, string $handler)
    {
        if (is_string($methods)) {
            $methods = (array) $methods;
        }

        $methods = array_map('strtoupper', $methods);

        $this->routes[] = [
            $methods,
            $pattern,
            $handler
        ];
    }
433168
public function prefix(string $prefix): Route
	{
		if(!empty($prefix))
		{
			$this->prefix .= '/' . trim($prefix, '/');
		}

		return $this;
	}
1058040
private void applyRoute(final Builder builder) {
        assertLocked();
        
        String route = cfg.getRoute();
        if (route != null) {
            builder.setAttribute(Attributes.ROUTE, route);
        }
    }
665062
private function addRoute(RouteCollection $routeCollection, string $resourceClass, string $operationName, array $operation, ResourceMetadata $resourceMetadata, string $operationType): void
    {
        $resourceShortName = $resourceMetadata->getShortName();

        if (isset($operation['route_name'])) {
            return;
        }

        if (!isset($operation['method'])) {
            throw new RuntimeException(sprintf('Either a "route_name" or a "method" operation attribute must exist for the operation "%s" of the resource "%s".', $operationName, $resourceClass));
        }

        if (null === $controller = $operation['controller'] ?? null) {
            $controller = sprintf('%s%s_%s', self::DEFAULT_ACTION_PATTERN, strtolower($operation['method']), $operationType);

            if (!$this->container->has($controller)) {
                throw new RuntimeException(sprintf('There is no builtin action for the %s %s operation. You need to define the controller yourself.', $operationType, $operation['method']));
            }
        }

        $path = trim(trim($resourceMetadata->getAttribute('route_prefix', '')), '/');
        $path .= $this->operationPathResolver->resolveOperationPath($resourceShortName, $operation, $operationType, $operationName);

        $route = new Route(
            $path,
            [
                '_controller' => $controller,
                '_format' => null,
                '_api_resource_class' => $resourceClass,
                sprintf('_api_%s_operation_name', $operationType) => $operationName,
            ] + ($operation['defaults'] ?? []),
            $operation['requirements'] ?? [],
            $operation['options'] ?? [],
            $operation['host'] ?? '',
            $operation['schemes'] ?? [],
            [$operation['method']],
            $operation['condition'] ?? ''
        );

        $routeCollection->add(RouteNameGenerator::generate($operationName, $resourceShortName, $operationType), $route);
    }
1114092
protected function localizeCollectionLocaleParameter($prefix, RouteCollection $collection)
    {
        $localizedPrefixes = array();
        foreach ($collection->all() as $name => $route) {
            $locale = $route->getDefault(self::LOCALE_PARAM);
            if ($locale === null) {
                // No locale so nothing to do
                $routePrefix = $prefix;
            } else {
                // A locale was found so localize the prefix
                if (!isset($localizedPrefixes[$locale])) {
                    $localizedPrefixes[$locale] = preg_replace(static::LOCALE_REGEX, $locale, $prefix);
                }
                $routePrefix = $localizedPrefixes[$locale];
            }
            $route->setPath('/' . $routePrefix . $route->getPath());
        }
    }
902832
private function buildRoutes(): void
    {
        if ($this->loaded['routes']) {
            return;
        }

        $this->loaded['routes'] = true;

        $this->routes = new RouteCollection(
            $this->getBaseCodeRoute(),
            $this->getBaseRouteName(),
            $this->getBaseRoutePattern(),
            $this->getBaseControllerName()
        );

        $this->routeBuilder->build($this, $this->routes);

        $this->configureRoutes($this->routes);

        foreach ($this->getExtensions() as $extension) {
            $extension->configureRoutes($this, $this->routes);
        }
    }
70714
public function compileRouter(RouteCollection $routes)
    {
        $routeTree = $this->treeBuilder->build($routes->asArray());
        $routeTree = $this->treeOptimizer->optimize($routeTree);

        $code         = new PhpBuilder();
        $code->indent = 1;
        $this->compileRouteTree($code, $routeTree);

        $rootRouteCode = new PhpBuilder();
        $rootRouteCode->indent = 2;
        if ($routeTree->hasRootRoute()) {
            $this->compiledRouteHttpMethodMatch($rootRouteCode, $routeTree->getRootRouteData(), array());
        } else {
            $this->compileNotFound($rootRouteCode);
        }

        return $this->formatPhpRouterTemplate(substr($rootRouteCode->getCode(), 0, -strlen(PHP_EOL)), $code->getCode());
    }