nextcloud/lib/route.php

68 lines
1.3 KiB
PHP
Raw Normal View History

<?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));
return $this;
}
public function post() {
2012-08-01 00:33:11 +04:00
$this->method('POST');
return $this;
}
public function get() {
2012-08-01 00:33:11 +04:00
$this->method('GET');
return $this;
}
public function put() {
2012-08-01 00:33:11 +04:00
$this->method('PUT');
return $this;
}
public function delete() {
2012-08-01 00:33:11 +04:00
$this->method('DELETE');
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'];
}
if ($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;
}
}