Merged in feature/HOR-2582 (pull request #5401)

HOR-2582

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Ronald Henry Quenta Apaza
2017-02-15 21:50:05 +00:00
committed by Julio Cesar Laura Avendaño
5 changed files with 134 additions and 3 deletions

View File

@@ -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
*

View File

@@ -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
*