Gets the UrlMatcher instance associated with this Router.
UrlMatcherInterface A UrlMatcherInterface instance
public function getMatcher() {
if (null !== $this->matcher) {
return $this->matcher;
}
if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
return $this->matcher = new $this->options['matcher_class']($this
->getRouteCollection(), $this->context);
}
$class = $this->options['matcher_cache_class'];
$cache = new ConfigCache($this->options['cache_dir'] . '/' . $class . '.php', $this->options['debug']);
if (!$cache
->isFresh($class)) {
$dumper = new $this->options['matcher_dumper_class']($this
->getRouteCollection());
$options = array(
'class' => $class,
'base_class' => $this->options['matcher_base_class'],
);
$cache
->write($dumper
->dump($options), $this
->getRouteCollection()
->getResources());
}
require_once $cache;
return $this->matcher = new $class($this->context);
}