summaryrefslogtreecommitdiffstats
path: root/lib/route.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-07-23 18:58:52 +0200
committerBart Visscher <bartv@thisnet.nl>2012-07-23 18:58:52 +0200
commit768b44b9b685a07af6030e484ab6322ba44b5b7e (patch)
tree23df0049a675a65447643ca7ef3a18a21841aa7f /lib/route.php
parentd0cae6a99a332af79b2506205aa25aad4313d912 (diff)
downloadnextcloud-server-768b44b9b685a07af6030e484ab6322ba44b5b7e.tar.gz
nextcloud-server-768b44b9b685a07af6030e484ab6322ba44b5b7e.zip
Convert routing to ownCloud fluid interface
Diffstat (limited to 'lib/route.php')
-rw-r--r--lib/route.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/route.php b/lib/route.php
new file mode 100644
index 00000000000..4344c977113
--- /dev/null
+++ b/lib/route.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+use Symfony\Component\Routing\Route;
+
+class OC_Route extends Route {
+ public function method($method) {
+ $this->setRequirement('_method', $method);
+ return $this;
+ }
+
+ public function post() {
+ $this->method('post');
+ return $this;
+ }
+
+ public function defaults($defaults) {
+ $action = $this->getDefault('action');
+ $this->setDefaults($defaults);
+ if (isset($defaults['action'])) {
+ $action = $defaults['action'];
+ }
+ $this->action($action);
+ return $this;
+ }
+
+ public function requirements($requirements) {
+ $method = $this->getRequirement('_method');
+ $this->setRequirements($requirements);
+ if (isset($requirements['_method'])) {
+ $method = $requirements['_method'];
+ }
+ $this->method($method);
+ return $this;
+ }
+
+ public function action($class, $function = null) {
+ $action = array($class, $function);
+ if (is_null($function)) {
+ $action = $class;
+ }
+ $this->setDefault('action', $action);
+ return $this;
+ }
+}