/**
  * {@inheritdoc}
  */
 public function parseResources()
 {
     if (null !== $this->stopwatch) {
         $this->stopwatch->start('routeCollection');
     }
     if (empty($this->resources)) {
         /*
          * Adding Backend routes
          */
         $this->addBackendCollection();
         /*
          * Add Assets controller routes
          */
         $assets = AssetsController::getRoutes();
         if ('' != $this->assetsHost) {
             $assets->setHost($this->assetsHost);
         }
         $this->addCollection($assets);
         /*
          * Add Entry points controller routes
          */
         $this->addCollection(EntryPointsController::getRoutes());
         /*
          * Add Frontend routes
          *
          * return 'RZ\Roadiz\CMS\Controllers\FrontendController';
          */
         $this->addThemesCollections();
     }
     if (null !== $this->stopwatch) {
         $this->stopwatch->stop('routeCollection');
     }
 }
 /**
  * @param string $backendClassname
  * @param array  $frontendThemes
  * @param string $assetsHost
  */
 public function __construct($backendClassname, array $frontendThemes, $assetsHost = '')
 {
     $this->backendClassname = $backendClassname;
     $this->frontendThemes = $frontendThemes;
     /*
      * Adding Backend routes
      */
     $this->addBackendCollection();
     /*
      * Add Assets controller routes
      */
     $assets = AssetsController::getRoutes();
     if ('' != $assetsHost) {
         $assets->setHost($assetsHost);
     }
     $this->addCollection($assets);
     /*
      * Add Entry points controller routes
      */
     $this->addCollection(EntryPointsController::getRoutes());
     /*
      * Add Frontend routes
      *
      * return 'RZ\Roadiz\CMS\Controllers\FrontendController';
      */
     $this->addThemesCollections();
 }
 public function register(Container $container)
 {
     $container['request'] = function ($c) {
         return Request::createFromGlobals();
     };
     $container['requestStack'] = function ($c) {
         $stack = new RequestStack();
         $stack->push($c['request']);
         return $stack;
     };
     $container['requestContext'] = function ($c) {
         $rc = new RequestContext();
         $rc->fromRequest($c['request']);
         return $rc;
     };
     $container['resolver'] = function ($c) {
         return new ControllerResolver();
     };
     $container['httpKernel'] = function ($c) {
         return new HttpKernel($c['dispatcher'], $c['resolver'], $c['requestStack']);
     };
     $container['urlMatcher'] = function ($c) {
         if (RouteCollectionSubscriber::needToDumpUrlTools()) {
             return new UrlMatcher($c['routeCollection'], $c['requestContext']);
         } else {
             return new MixedUrlMatcher($c['requestContext'], $c['dynamicUrlMatcher'], (bool) $c['config']['install']);
         }
     };
     $container['dynamicUrlMatcher'] = function ($c) {
         return new NodeUrlMatcher($c['requestContext'], $c['em']);
     };
     $container['urlGeneratorClass'] = function ($c) {
         return '\\GlobalUrlGenerator';
     };
     $container['urlGenerator'] = function ($c) {
         if (RouteCollectionSubscriber::needToDumpUrlTools()) {
             return new UrlGenerator($c['routeCollection'], $c['requestContext'], $c['logger']);
         } else {
             $className = $c['urlGeneratorClass'];
             return new $className($c['requestContext']);
         }
     };
     $container['httpUtils'] = function ($c) {
         return new HttpUtils($c['urlGenerator'], $c['urlMatcher']);
     };
     $container['routeListener'] = function ($c) {
         return new RouterListener($c['urlMatcher'], $c['requestContext'], null, $c['requestStack']);
     };
     if (isset($container['config']['install']) && true === $container['config']['install']) {
         /*
          * Get Install routes
          */
         $container['routeCollection'] = function ($c) {
             $installClassname = Kernel::INSTALL_CLASSNAME;
             $feCollection = $installClassname::getRoutes();
             $rCollection = new RouteCollection();
             $rCollection->addCollection($feCollection);
             $installClassname::setupDependencyInjection($c);
             return $rCollection;
         };
     } else {
         /*
          * Get App routes
          */
         $container['routeCollection'] = function ($c) {
             $c['stopwatch']->start('routeCollection');
             $rCollection = new RouteCollection();
             /*
              * Add Assets controller routes
              */
             $rCollection->addCollection(\RZ\Roadiz\CMS\Controllers\AssetsController::getRoutes());
             /*
              * Add Entry points controller routes
              */
             $rCollection->addCollection(\RZ\Roadiz\CMS\Controllers\EntryPointsController::getRoutes());
             /*
              * Add Backend routes
              */
             $beClass = $c['backendClass'];
             $cmsCollection = $beClass::getRoutes();
             if ($cmsCollection !== null) {
                 $rCollection->addCollection($cmsCollection);
             }
             /*
              * Add Frontend routes
              *
              * return 'RZ\Roadiz\CMS\Controllers\FrontendController';
              */
             foreach ($c['frontendThemes'] as $theme) {
                 $feClass = $theme->getClassName();
                 $feCollection = $feClass::getRoutes();
                 $feBackendCollection = $feClass::getBackendRoutes();
                 if ($feCollection !== null) {
                     // set host pattern if defined
                     if ($theme->getHostname() != '*' && $theme->getHostname() != '') {
                         $feCollection->setHost($theme->getHostname());
                     }
                     /*
                      * Add a global prefix on theme static routes
                      */
                     if ($theme->getRoutePrefix() != '') {
                         $feCollection->addPrefix($theme->getRoutePrefix());
                     }
                     $rCollection->addCollection($feCollection);
                 }
                 if ($feBackendCollection !== null) {
                     /*
                      * Do not prefix or hostname admin routes.
                      */
                     $rCollection->addCollection($feBackendCollection);
                 }
             }
             $c['stopwatch']->stop('routeCollection');
             return $rCollection;
         };
     }
     return $container;
 }