Record the app that is registering a call to use later with OAuth

This commit is contained in:
Tom Needham 2012-07-30 12:56:01 +00:00
parent 9ffaea480f
commit b563dff10a
1 changed files with 5 additions and 4 deletions

View File

@ -36,15 +36,16 @@ class OC_API {
* @param string $method the http method
* @param string $url the url to match
* @param callable $action the function to run
* @param string $app the id of the app registering the call
*/
public static function register($method, $url, $action){
public static function register($method, $url, $action, $app){
$name = strtolower($method).$url;
if(!isset(self::$actions[$name])){
OC_Router::create($name, $url.'.{format}')
->action('OC_API', 'call');
self::$actions[$name] = array();
}
self::$actions[$name][] = $action;
self::$actions[$name][] = array('app' => $app, 'action' => $action);
}
/**
@ -68,8 +69,8 @@ class OC_API {
$response = array();
// Loop through registered actions
foreach(self::$actions[$name] as $action){
if(is_callable($action)){
$action_response = call_user_func($action, $parameters);
if(is_callable($action['action'])){
$action_response = call_user_func($action['action'], $parameters);
if(is_array($action_response)){
// Merge with previous
$response = array_merge($response, $action_response);