]> source.dussan.org Git - nextcloud-server.git/commitdiff
Load the routes when matching or generating a route instead of when creating the...
authorRobin Appelman <icewind@owncloud.com>
Mon, 24 Mar 2014 13:55:03 +0000 (14:55 +0100)
committerRobin Appelman <icewind@owncloud.com>
Mon, 24 Mar 2014 13:55:03 +0000 (14:55 +0100)
lib/private/route/router.php
lib/private/server.php
lib/public/route/irouter.php

index 60ba587840157fda6470df7b2016c947ddd5240a..806bbf51abf8f04ef8a53683a3c7c640e7068a8c 100644 (file)
@@ -158,6 +158,7 @@ class Router implements IRouter {
         * @throws \Exception
         */
        public function match($url) {
+               $this->loadRoutes();
                $matcher = new UrlMatcher($this->root, $this->context);
                $parameters = $matcher->match($url);
                if (isset($parameters['action'])) {
@@ -196,6 +197,7 @@ class Router implements IRouter {
         * @return string
         */
        public function generate($name, $parameters = array(), $absolute = false) {
+               $this->loadRoutes();
                return $this->getGenerator()->generate($name, $parameters, $absolute);
        }
 
index 8c9ea39c5627b083585e616bc84d631de0a77b6e..5c83f3ef495acb49b90d5bb8fc8061bbf423de42 100644 (file)
@@ -159,7 +159,15 @@ class Server extends SimpleContainer implements IServerContainer {
                        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;
                });
        }
@@ -327,7 +335,7 @@ class Server extends SimpleContainer implements IServerContainer {
        /**
         * Returns an \OCP\CacheFactory instance
         *
-        * @return \OCP\CacheFactory
+        * @return \OCP\ICacheFactory
         */
        function getMemCacheFactory() {
                return $this->query('MemCacheFactory');
@@ -375,8 +383,6 @@ class Server extends SimpleContainer implements IServerContainer {
         * @return \OCP\Route\IRouter
         */
        function getRouter(){
-               $router = $this->query('Router');
-               $router->loadRoutes();
-               return $router;
+               return $this->query('Router');
        }
 }
index d6b0750ba6f0b60c6f75dcbb61bf933006b258e8..df397bc875891bf0dea29b5b14b933d4af742062 100644 (file)
@@ -10,8 +10,6 @@ namespace OCP\Route;
 
 interface IRouter {
 
-       public function __construct();
-
        /**
         * Get the files to load the routes from
         *