public getMatcher ( ) : UrlMatcherInterface | ||
return | 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, $this->defaults);
}
$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, $this->defaults);
}
public function loadRoutes($path, $options = array()) { $filelocator = new FileLocator($path); $routeloader = new YamlFileLoader($filelocator); $router = new Router($routeloader, $path, $options); $matcher = $router->getMatcher(); $routeCollection = $router->getRouteCollection(); $context = $router->getContext(); $this->dispatcher->addSubscriber(new HttpKernel\EventListener\RouterListener($matcher)); $this->shared['url.generator'] = new UrlGenerator($routeCollection, $context); $this->router = $router; return $router->getRouteCollection(); }