Change access to router object to getter function

This commit is contained in:
Bart Visscher 2012-08-02 17:47:38 +02:00
parent 93daa9e247
commit 7952c6a31c
3 changed files with 16 additions and 10 deletions

View File

@ -44,7 +44,7 @@ class OC_API {
$name = strtolower($method).$url;
$name = str_replace(array('/', '{', '}'), '_', $name);
if(!isset(self::$actions[$name])){
OC::$router->create($name, $url.'.{_format}')
OC::getRouter()->create($name, $url.'.{_format}')
->method($method)
->defaults(array('_format' => 'xml') + $defaults)
->requirements(array('_format' => 'xml|json') + $requirements)

View File

@ -62,14 +62,14 @@ class OC{
* requested file of app
*/
public static $REQUESTEDFILE = '';
/*
* OC router
*/
public static $router = null;
/**
* check if owncloud runs in cli mode
*/
public static $CLI = false;
/*
* OC router
*/
protected static $router = null;
/**
* SPL autoload
*/
@ -275,6 +275,14 @@ class OC{
}
}
public static function getRouter() {
if (!isset(OC::$router)) {
OC::$router = new OC_Router();
}
return OC::$router;
}
public static function init(){
// register autoloader
spl_autoload_register(array('OC','autoload'));
@ -358,8 +366,6 @@ class OC{
OC_User::useBackend(new OC_User_Database());
OC_Group::useBackend(new OC_Group_Database());
OC::$router = new OC_Router();
// Load Apps
// This includes plugins for users and filesystems as well
global $RUNTIME_NOAPPS;

View File

@ -25,11 +25,11 @@ require_once('../lib/base.php');
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
OC::$router->useCollection('ocs');
OC::$router->loadRoutes();
OC::getRouter()->useCollection('ocs');
OC::getRouter()->loadRoutes();
try {
OC::$router->match($_SERVER['PATH_INFO']);
OC::getRouter()->match($_SERVER['PATH_INFO']);
} catch (ResourceNotFoundException $e) {
OC_OCS::notFound();
} catch (MethodNotAllowedException $e) {