public function Router::getMatcher

Gets the UrlMatcher instance associated with this Router.

Return value

UrlMatcherInterface A UrlMatcherInterface instance

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php, line 188

Class

Router
The Router class is an example of the integration of all pieces of the routing system for easier use.

Namespace

Symfony\Component\Routing

Code

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);
}