Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class PhpMatcherDumper extends MatcherDumper
{
private $expressionLanguage;

/**
* @param ExpressionLanguage $expressionLanguage
*/
public function setExpressionLanguage(ExpressionLanguage $expressionLanguage = null)
{
$this->expressionLanguage = $expressionLanguage;
}

/**
* Dumps a set of routes to a PHP class.
*
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/Routing/Matcher/UrlMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ public function getContext()
return $this->context;
}

/**
* @param ExpressionLanguage $expressionLanguage
*/
public function setExpressionLanguage(ExpressionLanguage $expressionLanguage = null)
{
$this->expressionLanguage = $expressionLanguage;
}

/**
* {@inheritdoc}
*/
Expand Down
31 changes: 29 additions & 2 deletions src/Symfony/Component/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\ConfigCache;
use Psr\Log\LoggerInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Routing\Generator\ConfigurableRequirementsInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Generator\Dumper\GeneratorDumperInterface;
Expand Down Expand Up @@ -70,6 +71,11 @@ class Router implements RouterInterface, RequestMatcherInterface
*/
protected $logger;

/**
* @var ExpressionLanguage|null
*/
private $expressionLanguage;

/**
* Constructor.
*
Expand Down Expand Up @@ -150,6 +156,14 @@ public function setOption($key, $value)
$this->options[$key] = $value;
}

/**
* @param ExpressionLanguage $expressionLanguage
*/
public function setExpressionLanguage(ExpressionLanguage $expressionLanguage = null)
{
$this->expressionLanguage = $expressionLanguage;
}

/**
* Gets an option value.
*
Expand Down Expand Up @@ -245,13 +259,21 @@ public function getMatcher()
}

if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
return $this->matcher = new $this->options['matcher_class']($this->getRouteCollection(), $this->context);
$this->matcher = new $this->options['matcher_class']($this->getRouteCollection(), $this->context);
if (method_exists($this->matcher, 'setExpressionLanguage')) {
$this->matcher->setExpressionLanguage($this->expressionLanguage);
}

return $this->matcher;
}

$class = $this->options['matcher_cache_class'];
$cache = new ConfigCache($this->options['cache_dir'].'/'.$class.'.php', $this->options['debug']);
if (!$cache->isFresh()) {
$dumper = $this->getMatcherDumperInstance();
if (method_exists($dumper, 'setExpressionLanguage')) {
$dumper->setExpressionLanguage($this->expressionLanguage);
}

$options = array(
'class' => $class,
Expand All @@ -263,7 +285,12 @@ public function getMatcher()

require_once $cache;

return $this->matcher = new $class($this->context);
$this->matcher = new $class($this->context);
if (method_exists($this->matcher, 'setExpressionLanguage')) {
$this->matcher->setExpressionLanguage($this->expressionLanguage);
}

return $this->matcher;
}

/**
Expand Down