Fix for running doing routing in lib/ocs.php

remotes/origin/stable5
Bart Visscher 14 years ago
parent f63b9b44d8
commit 87d1cdb945
  1. 7
      lib/ocs.php
  2. 4
      lib/route.php
  3. 8
      lib/router.php

@ -23,6 +23,9 @@
* *
*/ */
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
/** /**
* Class to handle open collaboration services API requests * Class to handle open collaboration services API requests
* *
@ -93,7 +96,7 @@ class OC_OCS {
$format = self::readData($method, 'format', 'text', ''); $format = self::readData($method, 'format', 'text', '');
$router = new OC_Router(); $router = new OC_Router();
$router->useCollection('ocs'); $router->useCollection('root');
// CONFIG // CONFIG
$router->create('config', '/config.{format}') $router->create('config', '/config.{format}')
->defaults(array('format' => $format)) ->defaults(array('format' => $format))
@ -247,6 +250,8 @@ class OC_OCS {
$txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; $txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
$txt.=OC_OCS::getdebugoutput(); $txt.=OC_OCS::getdebugoutput();
echo(OC_OCS::generatexml($format,'failed',999,$txt)); echo(OC_OCS::generatexml($format,'failed',999,$txt));
} catch (MethodNotAllowedException $e) {
OC_Response::setStatus(405);
} }
exit(); exit();
} }

@ -50,7 +50,9 @@ class OC_Route extends Route {
if (isset($requirements['_method'])) { if (isset($requirements['_method'])) {
$method = $requirements['_method']; $method = $requirements['_method'];
} }
$this->method($method); if ($method) {
$this->method($method);
}
return $this; return $this;
} }

@ -10,19 +10,21 @@ use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
//use Symfony\Component\Routing\Route; //use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
class OC_Router { class OC_Router {
protected $collections = array(); protected $collections = array();
protected $collection = null; protected $collection = null;
protected $root = null; protected $root = null;
public function __construct() {
// TODO cache
$this->root = $this->getCollection('root');
}
/** /**
* loads the api routes * loads the api routes
*/ */
public function loadRoutes() { public function loadRoutes() {
// TODO cache
$this->root = $this->getCollection('root');
foreach(OC_APP::getEnabledApps() as $app){ foreach(OC_APP::getEnabledApps() as $app){
$file = OC_App::getAppPath($app).'/appinfo/routes.php'; $file = OC_App::getAppPath($app).'/appinfo/routes.php';
if(file_exists($file)){ if(file_exists($file)){

Loading…
Cancel
Save