Move loading of routes to OC::getRouter function

This commit is contained in:
Bart Visscher 2012-08-02 17:59:18 +02:00
parent 37ef522b05
commit 6ba2623485
3 changed files with 7 additions and 2 deletions

View File

@ -278,6 +278,7 @@ class OC{
public static function getRouter() {
if (!isset(OC::$router)) {
OC::$router = new OC_Router();
OC::$router->loadRoutes();
}
return OC::$router;

View File

@ -16,10 +16,15 @@ class OC_Router {
protected $collections = array();
protected $collection = null;
public function __construct() {
// TODO cache
$this->loadRoutes();
}
/**
* loads the api routes
*/
public function loadRoutes(){
public function loadRoutes() {
// TODO cache
foreach(OC_APP::getEnabledApps() as $app){
$file = OC_App::getAppPath($app).'/appinfo/routes.php';

View File

@ -26,7 +26,6 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
OC::getRouter()->useCollection('ocs');
OC::getRouter()->loadRoutes();
try {
OC::getRouter()->match($_SERVER['PATH_INFO']);