summaryrefslogtreecommitdiffstats
path: root/lib/router.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-10-05 17:42:42 +0200
committerBart Visscher <bartv@thisnet.nl>2012-10-05 17:42:46 +0200
commitc2b4e534534e083147bbad9b564179832cfa2912 (patch)
tree22810aaea097b37b5987b70f547a3de8b79c06d2 /lib/router.php
parentf3a211c03c3dd017e263ac5226a52eb62562d198 (diff)
downloadnextcloud-server-c2b4e534534e083147bbad9b564179832cfa2912.tar.gz
nextcloud-server-c2b4e534534e083147bbad9b564179832cfa2912.zip
Add API description to OC_Route and OC_Router
Diffstat (limited to 'lib/router.php')
-rw-r--r--lib/router.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/router.php b/lib/router.php
index 04a3d410060..a471a06802c 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -53,16 +53,34 @@ class OC_Router {
return $this->collections[$name];
}
+ /**
+ * Sets the collection to use for adding routes
+ *
+ * @param string $name Name of the colletion to use.
+ */
public function useCollection($name) {
$this->collection = $this->getCollection($name);
}
+ /**
+ * Create a OC_Route.
+ *
+ * @param string $name Name of the route to create.
+ * @param string $pattern The pattern to match
+ * @param array $defaults An array of default parameter values
+ * @param array $requirements An array of requirements for parameters (regexes)
+ */
public function create($name, $pattern, array $defaults = array(), array $requirements = array()) {
$route = new OC_Route($pattern, $defaults, $requirements);
$this->collection->add($name, $route);
return $route;
}
+ /**
+ * Find the route matching $url.
+ *
+ * @param string $url The url to find
+ */
public function match($url) {
$matcher = new UrlMatcher($this->root, $this->context);
$parameters = $matcher->match($url);
@@ -81,6 +99,10 @@ class OC_Router {
}
}
+ /**
+ * Get the url generator
+ *
+ */
public function getGenerator()
{
if (null !== $this->generator) {
@@ -90,11 +112,20 @@ class OC_Router {
return $this->generator = new UrlGenerator($this->root, $this->context);
}
+ /**
+ * Generate url based on $name and $parameters
+ *
+ * @param string $name Name of the route to use.
+ * @param array $parameters Parameters for the route
+ */
public function generate($name, $parameters = array(), $absolute = false)
{
return $this->getGenerator()->generate($name, $parameters, $absolute);
}
+ /**
+ * Generate JSON response for routing in javascript
+ */
public static function JSRoutes()
{
// TODO: http caching