Entry point of routes loader builder to
inject routes inside route loader.

@return ContainerBuilder
196785
public function build()
    {
        if ($this->container->hasDefinition($this->definitionName())) {
            $this->container->getDefinition(
                $this->definitionName()
            )->replaceArgument(0, array_unique($this->configuration, SORT_REGULAR));
        }
        if ($this->container->hasDefinition($this->definitionApiName())) {
            foreach ($this->configuration as $key => $config) {
                $this->configuration[$key]['enabled'] = $config['api_enabled'];

                if (array_key_exists('type', $config)) {
                    $this->configuration[$key]['type'] = $config['api_type'];
                }
            }

            $this->container->getDefinition(
                $this->definitionApiName()
            )->replaceArgument(0, array_unique($this->configuration, SORT_REGULAR));
        }

        return $this->container;
    }
227495
protected function requestHandler(): RequestHandlerInterface
    {
        if (!$this->hasContainer()) {
            throw new RouteException("Unable to configure route pipeline without associated container.");
        }

        if ($this->target instanceof TargetInterface) {
            try {
                return $this->target->getHandler($this->container, $this->matches);
            } catch (TargetException $e) {
                throw new RouteException("Invalid target resolution", $e->getCode(), $e);
            }
        }

        if ($this->target instanceof RequestHandlerInterface) {
            return $this->target;
        }

        try {
            if (is_object($this->target) || is_array($this->target)) {
                $target = $this->target;
            } else {
                $target = $this->container->get($this->target);
            }

            if ($target instanceof RequestHandlerInterface) {
                return $target;
            }

            return new CallableHandler(
                $target,
                $this->container->get(ResponseFactoryInterface::class)
            );
        } catch (ContainerExceptionInterface $e) {
            throw new RouteException($e->getMessage(), $e->getCode(), $e);
        }
    }
1201491
private static function init_routing()
    {
        static::$container->add_singleton(
            Router::class,
            function () {
                return new Router();
            }
        );

        static::$container->add_singleton(
            Request::class,
            function () {
                return new Request();
            }
        );

        static::$container->add_singleton(
            Response::class,
            function () {
                return new Response();
            }
        );

        static::$container->add_singleton(
            Validator::class,
            function () {
                return new Validator();
            }
        );

        static::$container->alias(Router::class, 'router');
        static::$container->alias(Request::class, 'request');
        static::$container->alias(Response::class, 'response');
    }
1127971
protected function init() {
        $this->container->set('logger', function($c) {
            $configuration = $c->get('configuration');

            $logger = new Logger($configuration['logger']);

            return $logger;
        });

        $this->container->set(MiddlewareFactory::class, function($c) {
            return new MiddlewareFactory();
        });

        $this->container->set('request', function($c) {
            $psr17Factory = new Psr17Factory();

            $creator = new ServerRequestCreator(
                $psr17Factory, // ServerRequestFactory
                $psr17Factory, // UriFactory
                $psr17Factory, // UploadedFileFactory
                $psr17Factory  // StreamFactory
            );

            return $creator->fromGlobals();
        });

        $this->container->set('router', function($c) {
            return new Router();
        });

        $this->container->set('response', function($c) {
            return new Response();
        });

        $this->container->set('view', function($c) {
            $configuration = $c->get('configuration')['view'];
            $viewFunctions = isset($configuration['viewFunctions']) ? $configuration['viewFunctions'] : [];
            return new Plates($configuration['viewPath'], $viewFunctions);
        });

        $this->registerErrorHandler();
    }
654899
protected function loadRoutes()
    {
        $builder = Router::createRouteBuilder('/');

        if ($this->app instanceof HttpApplicationInterface) {
            $this->app->routes($builder);
        }
        if ($this->app instanceof PluginApplicationInterface) {
            $this->app->pluginRoutes($builder);
        }
    }
391964
public function getRouteCollector(){
        if(null === $this->routeCollector){
            $this->routeCollector   = new RouteCollector();
            $resolver               = new Controller\ControllerResolver(
                $this,
                new \Doctrine\Common\Annotations\AnnotationReader(null)
            );

            foreach($this->bundles as $bundle){
                foreach($bundle->getControllers() as $controller){
                    foreach($resolver->getRoutes($controller) as $route){
                        $this->routeCollector->add($route);
                    }
                }
            }
        }

        return $this->routeCollector;
    }
667841
public function process(ContainerBuilder $container)
    {
        try {
            $chainRouter = $container->getDefinition("router.chainRequest");
        } catch (InvalidArgumentException $e) {
            return;
        }

        foreach ($container->findTaggedServiceIds("router.register") as $id => $attributes) {
            $priority = isset($attributes[0]["priority"]) ? $attributes[0]["priority"] : 0;
            $router = $container->getDefinition($id);
            $router->addMethodCall("setOption", array("matcher_cache_class", $container::camelize("ProjectUrlMatcher".$id)));
            $router->addMethodCall("setOption", array("generator_cache_class", $container::camelize("ProjectUrlGenerator".$id)));

            $chainRouter->addMethodCall("add", array(new Reference($id), $priority));
        }
        if (\defined("THELIA_INSTALL_MODE") === false) {
            $modules = ModuleQuery::getActivated();

            /** @var Module $module */
            foreach ($modules as $module) {
                $moduleBaseDir = $module->getBaseDir();
                $routingConfigFilePath = $module->getAbsoluteBaseDir() . DS . "Config" . DS . "routing.xml";

                if (file_exists($routingConfigFilePath)) {
                    $definition = new Definition(
                        $container->getParameter("router.class"),
                        array(
                            new Reference("router.module.xmlLoader"),
                            $routingConfigFilePath,
                            array(
                                "cache_dir" => $container->getParameter("kernel.cache_dir"),
                                "debug" => $container->getParameter("kernel.debug"),
                                "matcher_cache_class" => $container::camelize("ProjectUrlMatcher".$moduleBaseDir),
                                "generator_cache_class" => $container::camelize("ProjectUrlGenerator".$moduleBaseDir),
                            ),
                            new Reference("request.context")
                        )
                    );

                    $container->setDefinition("router.".$moduleBaseDir, $definition);

                    $chainRouter->addMethodCall("add", array(new Reference("router.".$moduleBaseDir), 150 + $module->getPosition()));
                }
            }
        }
    }
497070
protected function controllerMiddleware()
	{
		list( $class, $method ) = explode( '@', $this->action['uses'] );

		$controller = UniversalBuilder::resolve( $class );

		return ( new ControllerDispatcher( $this->router ) )->getMiddleware( $controller, $method );
	}
1269993
public function process(ContainerBuilder $container)
    {
        if (!$container->has('rollerworks_route_autowiring.route_loader') || !$container->getParameter('kernel.debug')) {
            return;
        }

        $trackedResources = array_map(
            function ($id) {
                return new Reference($id);
            },
            array_keys($container->findTaggedServiceIds(self::TAG_NAME))
        );

        $container->getDefinition('rollerworks_route_autowiring.route_loader')->replaceArgument(2, $trackedResources);
    }
896582
public function method(string ...$methods) : RouteBuilder
    {
        foreach ($this->routes as $route) {
            $route->allows($methods);
        }
        return $this;
    }
93967
public function build() : RouterInterface
    {
        $router = $this->router;
        foreach($this->routing_rules as $routing_rule => $events)
        {
            if (is_string($events)){
                try{
                    $router->bind($routing_rule, '*', $events);
                }
                catch(RoutingRuleBindingException $e)
                {
                    throw new RouterBuildingException('Rule binding failed:' . $routing_rule . ' event:' . $events, $e);
                }
            }
            else if (is_array($events)){
                foreach($events as $filter => $event){
                    try{
                        $router->bind($routing_rule, $filter, $event);
                    }
                    catch(RoutingRuleBindingException $e)
                    {
                        throw new RouterBuildingException('Rule binding failed:' . $routing_rule . ' event:' . $event . ' filter:' . $filter, $e);
                    }
                }
            }
        }
        return $router;
    }
154840
public function map()
    {
        Route::namespace($this->namespace)->group(function (Router $router) {

            /*
             * Front office routes
             */
            $router->middleware('web')->group(function (Router $router) {
                foreach (locales() as $lang) {
                    if (config('typicms.register')) {
                        // Registration
                        $router->get($lang.'/register', 'RegisterController@showRegistrationForm')->name($lang.'::register');
                        $router->post($lang.'/register', 'RegisterController@register');
                        // Verify
                        $router->get($lang.'/email/verify', 'VerificationController@show')->name($lang.'::verification.notice');
                        $router->get($lang.'/email/verify/{id}', 'VerificationController@verify')->name($lang.'::verification.verify');
                        $router->get($lang.'/email/resend', 'VerificationController@resend')->name($lang.'::verification.resend');
                    }
                    // Login
                    $router->get($lang.'/login', 'LoginController@showLoginForm')->name($lang.'::login');
                    $router->post($lang.'/login', 'LoginController@login');
                    // Request new password
                    $router->get($lang.'/password/reset', 'ForgotPasswordController@showLinkRequestForm')->name($lang.'::password.request');
                    $router->post($lang.'/password/email', 'ForgotPasswordController@sendResetLinkEmail')->name($lang.'::password.email');
                    // Set new password
                    $router->get($lang.'/password/reset/{token}', 'ResetPasswordController@showResetForm')->name($lang.'::password.reset');
                    $router->post($lang.'/password/reset', 'ResetPasswordController@reset');
                    // Logout
                    $router->post($lang.'/logout', 'LoginController@logout')->name($lang.'::logout');
                }
            });

            /*
             * Admin routes
             */
            $router->middleware('admin')->prefix('admin')->group(function (Router $router) {
                $router->get('users', 'AdminController@index')->name('admin::index-users')->middleware('can:see-all-users');
                $router->get('users/create', 'AdminController@create')->name('admin::create-user')->middleware('can:create-user');
                $router->get('users/{user}/edit', 'AdminController@edit')->name('admin::edit-user')->middleware('can:update-user');
                $router->post('users', 'AdminController@store')->name('admin::store-user')->middleware('can:create-user');
                $router->put('users/{user}', 'AdminController@update')->name('admin::update-user')->middleware('can:update-user');
            });

            /*
             * API routes
             */
            $router->middleware('api')->prefix('api')->group(function (Router $router) {
                $router->middleware('auth:api')->group(function (Router $router) {
                    $router->get('users', 'ApiController@index')->middleware('can:see-all-users');
                    $router->post('users/current/updatepreferences', 'ApiController@updatePreferences')->middleware('can:update-preferences');
                    $router->patch('users/{user}', 'ApiController@updatePartial')->middleware('can:update-user');
                    $router->delete('users/{user}', 'ApiController@destroy')->middleware('can:delete-user');
                });
            });
        });
    }
27269
public static function buildContainer(): Container
    {
        if (self::$container !== null) {
            return self::$container;
        }

        $factory = new ContainerBuilder();
        $factory->useAnnotations(true);

        if ((new ContextHelper())->isProduction()) {
            $factory->enableDefinitionCache();

            if (!is_dir(MELIOR_BASE.'/Data/Persistent/Container/Proxies')) {
                mkdir(MELIOR_BASE.'/Data/Persistent/Container/Proxies', 0755, true);
            }

            $factory->enableCompilation(MELIOR_BASE.'/Data/Persistent/Container');
            $factory->writeProxiesToFile(true, MELIOR_BASE.'/Data/Persistent/Container/Proxies');
        }

        $packages = (new PackageService(new PathHelper(), new ComposerParser()))->getApplicationPackages();

        foreach ($packages as $name => $data) {
            $extra = $data->getExtra();

            if (!array_key_exists('melior', $extra)) {
                continue;
            }

            $meliorData = $extra['melior'];

            if (!array_key_exists('containerDefinitions', $meliorData)) {
                continue;
            }

            $definitions = $meliorData['containerDefinitions'];

            if (is_string($definitions)) {
                $definitions = [$definitions];
            } elseif (!is_array($definitions)) {
                continue;
            }

            foreach ($definitions as $definitionFile) {
                $filepath = realpath("$name/$definitionFile");

                if (!is_file($filepath) || !\is_readable($filepath)) {
                    continue;
                }

                $factory->addDefinitions($filepath);
            }
        }

        $container = $factory->build();

        self::$container = $container;

        return $container;
    }
907980
protected function getContainerBuilder()
    {
        $container = new ContainerBuilder();
        $container->getParameterBag()->add($this->getKernelParameters());

        if ($this instanceof CompilerPassInterface) {
            $container->addCompilerPass($this, PassConfig::TYPE_BEFORE_OPTIMIZATION, -10000);
        }
        if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) {
            $container->setProxyInstantiator(new RuntimeInstantiator());
        }

        return $container;
    }
586990
public function mapPluginsFrontendRoutes()
    {
        foreach(Plugin::activePlugins() as $plugin){
            // Frontend routes
            $frontendRoutes = $plugin->frontendRoutes();
            if($frontendRoutes) {
                \Route::group(
                    [
                    'middleware' => $this->middleware['frontend'],
                    'as' => $plugin->namespaceWithDot().".",
                    'namespace' => $plugin->parseNamespace().'\Controllers',
                    ], function () use ($frontendRoutes) {
                        foreach($frontendRoutes as $file){
                            include $file->getPathname();
                        }
                    }
                );
            }
        }
        return $this;
    }
632094
public function buildRouter() : HTTPRouter
    {
        // create router dependencies and router instance
        $request = new HTTPInputRequestDefault();
        $response = new HTTPOutputResponseDefault($request);
        $errHandler = new HTTPErrorHandlerDefault();
        $router = new HTTPRouterDefault($request, $response, $errHandler);

        // prepare authorizations
        $authorizationDisabled = new AuthorizationDisabled();

        // add your routes here
        $router->addRoute(new HTTPRouteExample($request, $response, $authorizationDisabled));

        // return
        return $router;
    }
567396
public function loadContainer()
    {
        // pre-load Respond for Request->respond().
        $respond  = new Respond();
        if ($this->app->exists(ViewEngineInterface::class)) {
            $respond->setViewEngine($this->app->get(ViewEngineInterface::class));
        }
        if ($this->app->exists(ErrorView::class)) {
            $respond->setErrorViews($this->app->get(ErrorView::class));
        }
        $this->app->set(Respond::class, $respond);
        
        // pre-load Redirect for Request->redirect().
        $this->app->set(Redirect::class, new Redirect());

        // pre-load RouterStack. 
        $this->getRouterStack();
        return $this;
    }