2012-07-23 20:58:52 +04:00
|
|
|
<?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) {
|
2012-08-01 00:33:11 +04:00
|
|
|
$this->setRequirement('_method', strtoupper($method));
|
2012-07-23 20:58:52 +04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function post() {
|
2012-08-01 00:33:11 +04:00
|
|
|
$this->method('POST');
|
2012-07-23 20:58:52 +04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-07-25 19:45:29 +04:00
|
|
|
public function get() {
|
2012-08-01 00:33:11 +04:00
|
|
|
$this->method('GET');
|
2012-07-25 19:45:29 +04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function put() {
|
2012-08-01 00:33:11 +04:00
|
|
|
$this->method('PUT');
|
2012-07-25 19:45:29 +04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete() {
|
2012-08-01 00:33:11 +04:00
|
|
|
$this->method('DELETE');
|
2012-07-25 19:45:29 +04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-07-23 20:58:52 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|