[FrameworkBundle][Routing] Resolve placeholders in hostnamePattern rules
This commit is contained in:
parent
1b34ddb6b4
commit
c8e65a28e9
@ -78,6 +78,7 @@ class Router extends BaseRouter implements WarmableInterface
|
|||||||
* - the route defaults,
|
* - the route defaults,
|
||||||
* - the route requirements,
|
* - the route requirements,
|
||||||
* - the route pattern.
|
* - the route pattern.
|
||||||
|
* - the route hostnamePattern.
|
||||||
*
|
*
|
||||||
* @param RouteCollection $collection
|
* @param RouteCollection $collection
|
||||||
*/
|
*/
|
||||||
@ -96,6 +97,7 @@ class Router extends BaseRouter implements WarmableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$route->setPattern($this->resolve($route->getPattern()));
|
$route->setPattern($this->resolve($route->getPattern()));
|
||||||
|
$route->setHostnamePattern($this->resolve($route->getHostnamePattern()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,29 @@ class RoutingTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHostnamePatternPlaceholders()
|
||||||
|
{
|
||||||
|
$routes = new RouteCollection();
|
||||||
|
|
||||||
|
$route = new Route('foo');
|
||||||
|
$route->setHostnamePattern('/before/%parameter.foo%/after/%%unescaped%%');
|
||||||
|
|
||||||
|
$routes->add('foo', $route);
|
||||||
|
|
||||||
|
$sc = $this->getServiceContainer($routes);
|
||||||
|
|
||||||
|
$sc->expects($this->at(1))->method('hasParameter')->with('parameter.foo')->will($this->returnValue(true));
|
||||||
|
$sc->expects($this->at(2))->method('getParameter')->with('parameter.foo')->will($this->returnValue('foo'));
|
||||||
|
|
||||||
|
$router = new Router($sc, 'foo');
|
||||||
|
$route = $router->getRouteCollection()->get('foo');
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'/before/foo/after/%unescaped%',
|
||||||
|
$route->getHostnamePattern()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException
|
||||||
* @expectedExceptionMessage You have requested a non-existent parameter "nope".
|
* @expectedExceptionMessage You have requested a non-existent parameter "nope".
|
||||||
|
Reference in New Issue
Block a user