Merge pull request #6027 from owncloud/public-api-restful-routing-oc6

fix appframework routing
This commit is contained in:
Morris Jobke 2013-11-27 01:55:52 -08:00
commit a81909097c
3 changed files with 29 additions and 2 deletions

View File

@ -43,8 +43,12 @@ class App {
* stored in the DI container
* @param string $methodName the method that you want to call
* @param DIContainer $container an instance of a pimple container.
* @param array $urlParams list of URL parameters (optional)
*/
public static function main($controllerName, $methodName, IAppContainer $container) {
public static function main($controllerName, $methodName, DIContainer $container, array $urlParams = null) {
if (!is_null($urlParams)) {
$container['urlParams'] = $urlParams;
}
$controller = $container[$controllerName];
// initialize the dispatcher and run all the middleware before the controller

View File

@ -37,6 +37,6 @@ class RouteActionHandler {
}
public function __invoke($params) {
App::main($this->controllerName, $this->actionName, $params, $this->container);
App::main($this->controllerName, $this->actionName, $this->container, $params);
}
}

View File

@ -26,6 +26,7 @@
*/
namespace OCP\AppFramework;
use OC\AppFramework\routing\RouteConfig;
/**
@ -52,6 +53,28 @@ class App {
return $this->container;
}
/**
* This function is to be called to create single routes and restful routes based on the given $routes array.
*
* Example code in routes.php of tasks app (it will register two restful resources):
* $routes = array(
* 'resources' => array(
* 'lists' => array('url' => '/tasklists'),
* 'tasks' => array('url' => '/tasklists/{listId}/tasks')
* )
* );
*
* $a = new TasksApp();
* $a->registerRoutes($this, $routes);
*
* @param \OC_Router $router
* @param array $routes
*/
public function registerRoutes($router, $routes) {
$routeConfig = new RouteConfig($this->container, $router, $routes);
$routeConfig->register();
}
/**
* This function is called by the routing component to fire up the frameworks dispatch mechanism.
*