summaryrefslogtreecommitdiffstats
path: root/lib/route.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/route.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/route.php')
-rw-r--r--lib/route.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/route.php b/lib/route.php
index c5a8bd2aa36..89af829d3d3 100644
--- a/lib/route.php
+++ b/lib/route.php
@@ -9,31 +9,53 @@
use Symfony\Component\Routing\Route;
class OC_Route extends Route {
+ /**
+ * Specify the method when this route is to be used
+ *
+ * @param string $method HTTP method (uppercase)
+ */
public function method($method) {
$this->setRequirement('_method', strtoupper($method));
return $this;
}
+ /**
+ * Specify POST as the method to use with this route
+ */
public function post() {
$this->method('POST');
return $this;
}
+ /**
+ * Specify GET as the method to use with this route
+ */
public function get() {
$this->method('GET');
return $this;
}
+ /**
+ * Specify PUT as the method to use with this route
+ */
public function put() {
$this->method('PUT');
return $this;
}
+ /**
+ * Specify DELETE as the method to use with this route
+ */
public function delete() {
$this->method('DELETE');
return $this;
}
+ /**
+ * Defaults to use for this route
+ *
+ * @param array $defaults The defaults
+ */
public function defaults($defaults) {
$action = $this->getDefault('action');
$this->setDefaults($defaults);
@@ -44,6 +66,11 @@ class OC_Route extends Route {
return $this;
}
+ /**
+ * Requirements for this route
+ *
+ * @param array $requirements The requirements
+ */
public function requirements($requirements) {
$method = $this->getRequirement('_method');
$this->setRequirements($requirements);
@@ -56,6 +83,14 @@ class OC_Route extends Route {
return $this;
}
+ /**
+ * The action to execute when this route matches
+ * @param string|callable $class the class or a callable
+ * @param string $function the function to use with the class
+ *
+ * This function is called with $class set to a callable or
+ * to the class with $function
+ */
public function action($class, $function = null) {
$action = array($class, $function);
if (is_null($function)) {
@@ -65,6 +100,11 @@ class OC_Route extends Route {
return $this;
}
+ /**
+ * The action to execute when this route matches, includes a file like
+ * it is called directly
+ * @param $file
+ */
public function actionInclude($file) {
$function = create_function('$param', 'unset($param["_route"]);$_GET=array_merge($_GET,$param);unset($param);require_once "'.$file.'";');
$this->action($function);