Api: Route action param can be Callable ([$obj, $method])

This commit is contained in:
Frank Schubert
2023-11-30 16:28:18 +01:00
parent fb2af39cbd
commit 1e7a5e12a4
3 changed files with 36 additions and 6 deletions

View File

@@ -436,10 +436,9 @@ class mfBaseApicontroller {
}
//var_dump($params);exit;
$req_parts = explode("/", $params);
$req_count = count($req_parts);
foreach($this->routes as $route) {
if($route['method'] != $this->http_method) {
continue;
@@ -499,11 +498,17 @@ class mfBaseApicontroller {
}
private function call($function, $params = []) {
$args = $params;
if(count($params) === 1) {
return $this->__call($function,reset($params));
} else {
return $this->__call($function,$params);
$args = reset($params);
}
if(is_array($function)) {
return call_user_func($function, $args);
}
return $this->__call($function,$args);
}
protected function addRoute($route, $action, $method) {