If the matcher can not find information, it must throw one of the exceptions documented
below.
public matchRequest ( |
||
$request | The request to match | |
return | array | An array of parameters |
public function testMatchRequestVirtualWithCaseRedirect() { $pathInfo = '/Foo/bAR'; $urlAliasPath = '/foo/bar'; $urlAlias = new URLAlias( array( 'path' => $urlAliasPath, 'type' => UrlAlias::VIRTUAL, ) ); $request = $this->getRequestByPathInfo( $pathInfo ); $this->urlALiasGenerator ->expects( $this->once() ) ->method( 'isUriPrefixExcluded' ) ->with( $pathInfo ) ->will( $this->returnValue( false ) ); $this->urlAliasService ->expects( $this->once() ) ->method( 'lookup' ) ->with( $pathInfo ) ->will( $this->returnValue( $urlAlias ) ); $expected = array( '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME, ); $this->assertEquals( $expected, $this->router->matchRequest( $request ) ); $this->assertTrue( $request->attributes->get( 'needsRedirect' ) ); $this->assertSame( $urlAliasPath, $request->attributes->get( 'semanticPathinfo' ) ); }
public function matchRequest(Request $request) { // UrlAliasRouter might be disabled from configuration. // An example is for running the admin interface: it needs to be entirely run through the legacy kernel. if ($this->configResolver->getParameter('url_alias_router') === false) { throw new ResourceNotFoundException("Config says to bypass UrlAliasRouter"); } return parent::matchRequest($request); }
/** * @covers eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter::__construct * @covers eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter::getUrlAlias * @covers eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter::matchRequest */ public function testMatchRequestVirtualInternalForward() { $pathInfo = '/foo/bar'; $newPathInfo = '/foo/bar/baz'; $urlAlias = new URLAlias(array('path' => $pathInfo, 'type' => UrlAlias::VIRTUAL, 'destination' => $newPathInfo, 'forward' => false)); $request = $this->getRequestByPathInfo($pathInfo); $this->urlAliasService->expects($this->once())->method('lookup')->with($pathInfo)->will($this->returnValue($urlAlias)); $expected = array('_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME); $this->assertEquals($expected, $this->router->matchRequest($request)); $this->assertTrue($request->attributes->get('needsForward')); $this->assertSame($newPathInfo, $request->attributes->get('semanticPathinfo')); }