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['router'] = function ($c) { $router = new ChainRouter($c['logger']); $router->add($c['staticRouter']); $router->add($c['nodeRouter']); return $router; }; $container['staticRouter'] = function ($c) { return new StaticRouter($c['routeCollection'], ['cache_dir' => (bool) $c['config']['devMode'] ? null : ROADIZ_ROOT . '/cache/routing', 'debug' => (bool) $c['config']['devMode'], 'generator_cache_class' => 'StaticUrlGenerator', 'matcher_cache_class' => 'StaticUrlMatcher'], $c['requestContext'], $c['logger']); }; $container['nodeRouter'] = function ($c) { return new NodeRouter($c['em'], ['cache_dir' => (bool) $c['config']['devMode'] ? null : ROADIZ_ROOT . '/cache/routing', 'debug' => (bool) $c['config']['devMode'], 'generator_cache_class' => 'NodeUrlGenerator', 'matcher_cache_class' => 'NodeUrlMatcher'], $c['requestContext'], $c['logger'], $c['stopwatch']); }; $container['urlGenerator'] = function ($c) { return $c['staticRouter']->getGenerator(); }; $container['httpUtils'] = function ($c) { return new HttpUtils($c['router'], $c['router']); }; $container['routeListener'] = function ($c) { return new TimedRouteListener($c['router'], $c['requestContext'], null, $c['requestStack'], $c['stopwatch']); }; $container['routeCollection'] = function ($c) { if (isset($c['config']['install']) && true === $c['config']['install']) { /* * Get Install routes */ $installClassname = Kernel::INSTALL_CLASSNAME; $installClassname::setupDependencyInjection($c); return new InstallRouteCollection($installClassname); } else { /* * Get App routes */ $rCollection = new RoadizRouteCollection($c['backendClass'], $c['frontendThemes'], SettingsBag::get('static_domain_name'), $c['stopwatch']); return $rCollection; } }; return $container; }
/** * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException */ public function testSupport() { $router = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\VersatileRouter'); $router->expects($this->once())->method('supports')->will($this->returnValue(false)); $router->expects($this->never())->method('generate')->will($this->returnValue(false)); $this->router->add($router); $this->router->generate('foobar'); }