Merged in feature/HOR-2582 (pull request #5401)
HOR-2582 Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
a40689adb1
@@ -141,4 +141,53 @@ class Restler extends \Luracast\Restler\Restler
|
||||
{
|
||||
return $this->workspace;
|
||||
}
|
||||
|
||||
protected function call()
|
||||
{
|
||||
$this->dispatch('call');
|
||||
$o = &$this->apiMethodInfo;
|
||||
$accessLevel = max(\Luracast\Restler\Defaults::$apiAccessLevel, $o->accessLevel);
|
||||
$object = \Luracast\Restler\Scope::get($o->className);
|
||||
switch ($accessLevel) {
|
||||
case 3 : //protected method
|
||||
$reflectionMethod = new \ReflectionMethod(
|
||||
$object,
|
||||
$o->methodName
|
||||
);
|
||||
$reflectionMethod->setAccessible(true);
|
||||
$result = $reflectionMethod->invokeArgs(
|
||||
$object,
|
||||
$o->parameters
|
||||
);
|
||||
break;
|
||||
default :
|
||||
$object = $this->reviewApiExtensions($object, $o->className);
|
||||
$result = call_user_func_array(array(
|
||||
$object,
|
||||
$o->methodName
|
||||
), $o->parameters);
|
||||
}
|
||||
$this->responseData = $result;
|
||||
}
|
||||
|
||||
public function reviewApiExtensions($object, $className)
|
||||
{
|
||||
$classReflection = new \ReflectionClass($object);
|
||||
$classShortName = $classReflection->getShortName();
|
||||
$registry = &\PMPluginRegistry::getSingleton();
|
||||
$pluginsApiExtend = $registry->getExtendsRestService($classShortName);
|
||||
if ($pluginsApiExtend) {
|
||||
$classFilePath = $pluginsApiExtend['filePath'];
|
||||
if (file_exists($classFilePath)) {
|
||||
require_once($classFilePath);
|
||||
$classExtName = $pluginsApiExtend['classExtend'];
|
||||
$newObjectExt = new $classExtName();
|
||||
if (is_subclass_of($newObjectExt, $className)) {
|
||||
$object = $newObjectExt;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user