* @throws \Exception
*/
public function match($url) {
+ $this->loadRoutes();
$matcher = new UrlMatcher($this->root, $this->context);
$parameters = $matcher->match($url);
if (isset($parameters['action'])) {
* @return string
*/
public function generate($name, $parameters = array(), $absolute = false) {
+ $this->loadRoutes();
return $this->getGenerator()->generate($name, $parameters, $absolute);
}
return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
});
$this->registerService('Router', function ($c){
- $router = new \OC\Route\Router();
+ /**
+ * @var Server $c
+ */
+ $cacheFactory = $c->getMemCacheFactory();
+ if ($cacheFactory->isAvailable()) {
+ $router = new \OC\Route\CachingRouter($cacheFactory->create('route'));
+ } else {
+ $router = new \OC\Route\Router();
+ }
return $router;
});
}
/**
* Returns an \OCP\CacheFactory instance
*
- * @return \OCP\CacheFactory
+ * @return \OCP\ICacheFactory
*/
function getMemCacheFactory() {
return $this->query('MemCacheFactory');
* @return \OCP\Route\IRouter
*/
function getRouter(){
- $router = $this->query('Router');
- $router->loadRoutes();
- return $router;
+ return $this->query('Router');
}
}