fix Froxlor::listFunction() api-call after namespacing

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2019-01-02 18:36:01 +01:00
parent 5dda57458a
commit 92b133b11d

View File

@@ -247,10 +247,10 @@ class Froxlor extends \Froxlor\Api\ApiCommand
// check existence // check existence
$this->requireModules($module); $this->requireModules($module);
// now get all static functions // now get all static functions
$reflection = new \ReflectionClass($module); $reflection = new \ReflectionClass(__NAMESPACE__ . '\\' . $module);
$_functions = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC); $_functions = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($_functions as $func) { foreach ($_functions as $func) {
if ($func->class == $module && $func->isPublic()) { if ($func->class == __NAMESPACE__ . '\\' . $module && $func->isPublic()) {
array_push($functions, array_merge(array( array_push($functions, array_merge(array(
'module' => $module, 'module' => $module,
'function' => $func->name 'function' => $func->name
@@ -279,10 +279,10 @@ class Froxlor extends \Froxlor\Api\ApiCommand
continue; continue;
} }
// now get all static functions // now get all static functions
$reflection = new \ReflectionClass($mod); $reflection = new \ReflectionClass(__NAMESPACE__ . '\\' . $mod);
$_functions = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC); $_functions = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($_functions as $func) { foreach ($_functions as $func) {
if ($func->class == $mod && $func->isPublic() && ! $func->isStatic()) { if ($func->class == __NAMESPACE__ . '\\' . $mod && $func->isPublic() && ! $func->isStatic()) {
array_push($functions, array_merge(array( array_push($functions, array_merge(array(
'module' => $matches[1], 'module' => $matches[1],
'function' => $func->name 'function' => $func->name
@@ -414,7 +414,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
// check all the modules // check all the modules
foreach ($modules as $module) { foreach ($modules as $module) {
try { try {
$module = "\Froxlor\Api\Commands\\" . $module; $module = __NAMESPACE__ . '\\' . $module;
// can we use the class? // can we use the class?
if (class_exists($module)) { if (class_exists($module)) {
continue; continue;