From 8ab7d18a6a2b023527d2eef63099e2834c46ec97 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 10 Mar 2014 14:04:58 +0100 Subject: Move the router classes to a namespace and expose it with a public interface --- lib/base.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'lib/base.php') diff --git a/lib/base.php b/lib/base.php index 86ee5349828..d49dd958310 100644 --- a/lib/base.php +++ b/lib/base.php @@ -73,11 +73,6 @@ class OC { */ public static $CLI = false; - /** - * @var OC_Router - */ - protected static $router = null; - /** * @var \OC\Session\Session */ @@ -388,15 +383,10 @@ class OC { } /** - * @return OC_Router + * @return \OCP\Route\IRouter */ public static function getRouter() { - if (!isset(OC::$router)) { - OC::$router = new OC_Router(); - OC::$router->loadRoutes(); - } - - return OC::$router; + return self::$server->getRouter(); } -- cgit v1.2.3 From 26793e1f943012937776324698855108dd5352ba Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 10 Mar 2014 14:06:47 +0100 Subject: switch OC::getRouter usages to OC::$server->getRouter --- lib/base.php | 10 +--------- lib/private/api.php | 4 ++-- lib/private/urlgenerator.php | 2 +- ocs/v1.php | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) (limited to 'lib/base.php') diff --git a/lib/base.php b/lib/base.php index d49dd958310..4bc6c4329c4 100644 --- a/lib/base.php +++ b/lib/base.php @@ -382,14 +382,6 @@ class OC { return OC_Config::getValue('session_lifetime', 60 * 60 * 24); } - /** - * @return \OCP\Route\IRouter - */ - public static function getRouter() { - return self::$server->getRouter(); - } - - public static function loadAppClassPaths() { foreach (OC_APP::getEnabledApps() as $app) { $file = OC_App::getAppPath($app) . '/appinfo/classpath.php'; @@ -714,7 +706,7 @@ class OC { OC_App::loadApps(); } self::checkSingleUserMode(); - OC::getRouter()->match(OC_Request::getRawPathInfo()); + OC::$server->getRouter()->match(OC_Request::getRawPathInfo()); return; } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { //header('HTTP/1.0 404 Not Found'); diff --git a/lib/private/api.php b/lib/private/api.php index 3f96196e6df..cde24f78a55 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -65,8 +65,8 @@ class OC_API { $name = strtolower($method).$url; $name = str_replace(array('/', '{', '}'), '_', $name); if(!isset(self::$actions[$name])) { - OC::getRouter()->useCollection('ocs'); - OC::getRouter()->create($name, $url) + OC::$server->getRouter()->useCollection('ocs'); + OC::$server->getRouter()->create($name, $url) ->method($method) ->defaults($defaults) ->requirements($requirements) diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index 60da34f2d6e..44b46ef6700 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -39,7 +39,7 @@ class URLGenerator implements IURLGenerator { * Returns a url to the given app and file. */ public function linkToRoute($route, $parameters = array()) { - $urlLinkTo = \OC::getRouter()->generate($route, $parameters); + $urlLinkTo = \OC::$server->getRouter()->generate($route, $parameters); return $urlLinkTo; } diff --git a/ocs/v1.php b/ocs/v1.php index 1c7d1c89768..3da72e65f1c 100644 --- a/ocs/v1.php +++ b/ocs/v1.php @@ -26,7 +26,7 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\MethodNotAllowedException; try { - OC::getRouter()->match('/ocs'.OC_Request::getRawPathInfo()); + OC::$server->getRouter()->match('/ocs'.OC_Request::getRawPathInfo()); } catch (ResourceNotFoundException $e) { OC_OCS::notFound(); } catch (MethodNotAllowedException $e) { -- cgit v1.2.3