Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-08-02 23:51:31 +0400
committerBart Visscher <bartv@thisnet.nl>2012-08-02 23:51:31 +0400
commit4b9200f6f7a571c251ef89599e1af9e25e2e75f4 (patch)
tree3ba1e03e197c2e02fa8ec63a2738a3b0f08e3fc4 /lib/router.php
parent6ba2623485655460440a972e34a8a2a2fda02821 (diff)
Routing: combine all routes into one set
Diffstat (limited to 'lib/router.php')
-rw-r--r--lib/router.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/router.php b/lib/router.php
index 5c5171cf82d..12cd55df414 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -15,32 +15,38 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
class OC_Router {
protected $collections = array();
protected $collection = null;
-
- public function __construct() {
- // TODO cache
- $this->loadRoutes();
- }
+ protected $root = null;
/**
* loads the api routes
*/
public function loadRoutes() {
// TODO cache
+ $this->root = $this->getCollection('root');
foreach(OC_APP::getEnabledApps() as $app){
$file = OC_App::getAppPath($app).'/appinfo/routes.php';
if(file_exists($file)){
+ $this->useCollection($app);
require_once($file);
+ $collection = $this->getCollection($app);
+ $this->root->addCollection($collection, '/apps/'.$app);
}
}
// include ocs routes
require_once(OC::$SERVERROOT.'/ocs/routes.php');
+ $collection = $this->getCollection('ocs');
+ $this->root->addCollection($collection, '/ocs');
}
- public function useCollection($name) {
+ protected function getCollection($name) {
if (!isset($this->collections[$name])) {
$this->collections[$name] = new RouteCollection();
}
- $this->collection = $this->collections[$name];
+ return $this->collections[$name];
+ }
+
+ public function useCollection($name) {
+ $this->collection = $this->getCollection($name);
}
public function create($name, $pattern, array $defaults = array(), array $requirements = array()) {
@@ -51,7 +57,7 @@ class OC_Router {
public function match($url) {
$context = new RequestContext($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
- $matcher = new UrlMatcher($this->collection, $context);
+ $matcher = new UrlMatcher($this->root, $context);
$parameters = $matcher->match($url);
if (isset($parameters['action'])) {
$action = $parameters['action'];