[Routing] fix dumping conditions that use the request

This commit is contained in:
Nicolas Grekas 2018-11-06 21:23:18 +01:00
parent 8d277ce3e5
commit 09d5be8dac
2 changed files with 4 additions and 1 deletions

View File

@ -400,7 +400,7 @@ EOF;
if ($condition = $route->getCondition()) {
$condition = $this->getExpressionLanguage()->compile($condition, array('context', 'request'));
$condition = $conditions[$condition] ?? $conditions[$condition] = ((false !== strpos($condition, '$request')) - 1) * \count($conditions);
$condition = $conditions[$condition] ?? $conditions[$condition] = (false !== strpos($condition, '$request') ? 1 : -1) * \count($conditions);
} else {
$condition = 'null';
}

View File

@ -455,6 +455,9 @@ class UrlMatcherTest extends TestCase
{
$coll = new RouteCollection();
$route = new Route('/foo/{bar}');
$route->setCondition('request.getBaseUrl() == "/bar"');
$coll->add('bar', $route);
$route = new Route('/foo/{bar}');
$route->setCondition('request.getBaseUrl() == "/sub/front.php" and request.getPathInfo() == "/foo/bar"');
$coll->add('foo', $route);
$matcher = $this->getUrlMatcher($coll, new RequestContext('/sub/front.php'));