diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-07-23 18:58:52 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-07-23 18:58:52 +0200 |
commit | 768b44b9b685a07af6030e484ab6322ba44b5b7e (patch) | |
tree | 23df0049a675a65447643ca7ef3a18a21841aa7f /lib/route.php | |
parent | d0cae6a99a332af79b2506205aa25aad4313d912 (diff) | |
download | nextcloud-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.php | 50 |
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; + } +} |