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
@@ -27,7 +27,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"luracast/restler": "3.0.0-RC5",
|
||||
"luracast/restler": "^3.0",
|
||||
"bshaffer/oauth2-server-php": "v1.0",
|
||||
"colosa/pmUI": "release/3.2-dev",
|
||||
"colosa/MichelangeloFE": "release/3.2-dev",
|
||||
|
||||
4
composer.lock
generated
4
composer.lock
generated
@@ -192,7 +192,7 @@
|
||||
},
|
||||
{
|
||||
"name": "luracast/restler",
|
||||
"version": "3.0.0-RC5",
|
||||
"version": "3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Luracast/Restler.git",
|
||||
@@ -267,7 +267,7 @@
|
||||
"rest",
|
||||
"server"
|
||||
],
|
||||
"time": "2015-08-04T07:52:49+00:00"
|
||||
"time": "2017-01-11T03:42:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -349,6 +349,28 @@ class PMPlugin
|
||||
$oPluginRegistry->registerRestService($this->sNamespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a extend rest service and expose it
|
||||
*
|
||||
* @param string $className that is name class to extends
|
||||
*/
|
||||
function registerExtendsRestService($className)
|
||||
{
|
||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry->registerExtendsRestService($this->sNamespace, $className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a extend rest service and expose it
|
||||
*
|
||||
* @param string $className that is name class to extends
|
||||
*/
|
||||
function disableExtendsRestService($className)
|
||||
{
|
||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||
$oPluginRegistry->disableExtendsRestService($this->sNamespace, $className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a rest service
|
||||
*
|
||||
|
||||
@@ -117,6 +117,8 @@ class PMPluginRegistry
|
||||
*/
|
||||
private $_restServices = array ();
|
||||
|
||||
private $_restExtendServices = array ();
|
||||
|
||||
private $_restServiceEnabled = array();
|
||||
|
||||
private static $instance = null;
|
||||
@@ -427,6 +429,10 @@ class PMPluginRegistry
|
||||
if(sizeof( $this->_aOpenReassignCallback )){
|
||||
unset( $this->_aOpenReassignCallback );
|
||||
}
|
||||
|
||||
if (sizeof($this->_restExtendServices)) {
|
||||
$this->disableExtendsRestService($sNamespace);
|
||||
}
|
||||
//unregistering javascripts from this plugin
|
||||
$this->unregisterJavascripts( $sNamespace );
|
||||
//unregistering rest services from this plugin
|
||||
@@ -1458,6 +1464,60 @@ class PMPluginRegistry
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a extend rest service class from a plugin to be served by processmaker
|
||||
*
|
||||
* @param string $sNamespace The namespace for the plugin
|
||||
* @param string $className The service (api) class name
|
||||
*/
|
||||
public function registerExtendsRestService($sNamespace, $className)
|
||||
{
|
||||
$baseSrcPluginPath = PATH_PLUGINS . $sNamespace . PATH_SEP . "src";
|
||||
$apiPath = PATH_SEP . "Services" . PATH_SEP . "Ext" . PATH_SEP;
|
||||
$classFile = $baseSrcPluginPath . $apiPath . 'Ext' . $className . '.php';
|
||||
if (file_exists($classFile)) {
|
||||
$this->_restExtendServices[$sNamespace][$className] = array(
|
||||
"filePath" => $classFile,
|
||||
"classParent" => $className,
|
||||
"classExtend" => 'Ext' . $className
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a extend rest service class from a plugin to be served by processmaker
|
||||
*
|
||||
* @param string $className The service (api) class name
|
||||
* @return array
|
||||
*/
|
||||
public function getExtendsRestService($className)
|
||||
{
|
||||
$responseRestExtendService = array();
|
||||
foreach ($this->_restExtendServices as $sNamespace => $restExtendService) {
|
||||
if (isset($restExtendService[$className])) {
|
||||
$responseRestExtendService = $restExtendService[$className];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $responseRestExtendService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a extend rest service class from a plugin to be served by processmaker
|
||||
*
|
||||
* @param string $sNamespace
|
||||
* @param string $className The service (api) class name
|
||||
* @return bool
|
||||
*/
|
||||
public function disableExtendsRestService($sNamespace, $className = '')
|
||||
{
|
||||
if (isset($this->_restExtendServices[$sNamespace][$className]) && !empty($className)) {
|
||||
unset($this->_restExtendServices[$sNamespace][$className]);
|
||||
} elseif (empty($className)) {
|
||||
unset($this->_restExtendServices[$sNamespace]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a rest service class of a plugin
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user