introduce and use getCurrentConnection()

This commit is contained in:
Jörn Friedrich Dreyer 2014-07-01 16:45:00 +02:00
parent dd20b9f672
commit 5a588333b2
3 changed files with 25 additions and 1 deletions

View File

@ -65,6 +65,7 @@ class OC_API {
$name = strtolower($method).$url;
$name = str_replace(array('/', '{', '}'), '_', $name);
if(!isset(self::$actions[$name])) {
$oldCollection = OC::$server->getRouter()->getCurrentCollection();
OC::$server->getRouter()->useCollection('ocs');
OC::$server->getRouter()->create($name, $url)
->method($method)
@ -72,7 +73,7 @@ class OC_API {
->requirements($requirements)
->action('OC_API', 'call');
self::$actions[$name] = array();
OC::$server->getRouter()->useCollection('root');
OC::$server->getRouter()->useCollection($oldCollection);
}
self::$actions[$name][] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel);
}

View File

@ -25,6 +25,11 @@ class Router implements IRouter {
*/
protected $collection = null;
/**
* @var string
*/
protected $collectionName = null;
/**
* @var \Symfony\Component\Routing\RouteCollection
*/
@ -160,8 +165,19 @@ class Router implements IRouter {
*/
public function useCollection($name) {
$this->collection = $this->getCollection($name);
$this->collectionName = $name;
}
/**
* returns the current collection name in use for adding routes
*
* @return string the collection name
*/
public function getCurrentCollection() {
return $this->collectionName;
}
/**
* Create a \OC\Route\Route.
*

View File

@ -36,6 +36,13 @@ interface IRouter {
*/
public function useCollection($name);
/**
* returns the current collection name in use for adding routes
*
* @return string the collection name
*/
public function getCurrentCollection();
/**
* Create a \OCP\Route\IRoute.
*