public function matchRequest( Request $request ) { $attributes = parent::matchRequest( $request ); if ( isset( $attributes['_route'] ) && !$this->isLegacyAwareRoute( $attributes['_route'] ) && $this->configResolver->getParameter( 'legacy_mode' ) === true ) { throw new ResourceNotFoundException( "Legacy mode activated, default router is bypassed" ); } return $attributes; }
public function testGenerateReverseSiteAccessMatch() { $routeName = 'some_route_name'; $urlGenerated = 'http://phoenix-rises.fm/foo/bar'; $siteAccessName = 'foo_test'; $siteAccessRouter = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\SiteAccessRouterInterface'); $versatileMatcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher'); $simplifiedRequest = new SimplifiedRequest(array('host' => 'phoenix-rises.fm', 'scheme' => 'http')); $versatileMatcher->expects($this->once())->method('getRequest')->will($this->returnValue($simplifiedRequest)); $siteAccessRouter->expects($this->once())->method('matchByName')->with($siteAccessName)->will($this->returnValue(new SiteAccess($siteAccessName, 'foo', $versatileMatcher))); $generator = $this->getMock('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface'); $generator->expects($this->at(0))->method('setContext')->with($this->isInstanceOf('Symfony\\Component\\Routing\\RequestContext')); $generator->expects($this->at(1))->method('generate')->with($routeName)->will($this->returnValue($urlGenerated)); $generator->expects($this->at(2))->method('setContext')->with($this->requestContext); $router = new DefaultRouter($this->container, 'foo', array(), $this->requestContext); $router->setConfigResolver($this->configResolver); $router->setSiteAccess(new SiteAccess('test', 'test', $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\Matcher'))); $router->setSiteAccessRouter($siteAccessRouter); $refRouter = new ReflectionObject($router); $refGenerator = $refRouter->getProperty('generator'); $refGenerator->setAccessible(true); $refGenerator->setValue($router, $generator); $this->assertSame($urlGenerated, $router->generate($routeName, array('siteaccess' => $siteAccessName), DefaultRouter::ABSOLUTE_PATH)); }