[Pkg-owncloud-commits] [owncloud] 12/70: introduce and use getCurrentConnection()

David Prévot taffit at moszumanska.debian.org
Mon Jul 14 17:38:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit f390ae53ba98ccbdfcc60aad2ab03a35bcf77b2c
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date:   Tue Jul 1 16:45:00 2014 +0200

    introduce and use getCurrentConnection()
---
 lib/private/api.php          |  3 ++-
 lib/private/route/router.php | 16 ++++++++++++++++
 lib/public/route/irouter.php |  7 +++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/private/api.php b/lib/private/api.php
index 75d87b3..f5576af 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -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);
 	}
diff --git a/lib/private/route/router.php b/lib/private/route/router.php
index f3a4bc5..9c973d7 100644
--- a/lib/private/route/router.php
+++ b/lib/private/route/router.php
@@ -26,6 +26,11 @@ class Router implements IRouter {
 	protected $collection = null;
 
 	/**
+	 * @var string
+	 */
+	protected $collectionName = null;
+
+	/**
 	 * @var \Symfony\Component\Routing\RouteCollection
 	 */
 	protected $root = null;
@@ -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.
 	 *
diff --git a/lib/public/route/irouter.php b/lib/public/route/irouter.php
index 1c003c7..daa1632 100644
--- a/lib/public/route/irouter.php
+++ b/lib/public/route/irouter.php
@@ -37,6 +37,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.
 	 *
 	 * @param string $name Name of the route to create.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list