Merged in bugfix/HOR-3987 (pull request #6124)

HOR-3987

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Marco Antonio Nina Mena
2017-10-20 13:23:31 +00:00
committed by Julio Cesar Laura Avendaño
2 changed files with 307 additions and 299 deletions

View File

@@ -326,19 +326,19 @@ class PMPluginRegistry
}
}
if(sizeof( $this->_aMenuOptionsToReplace )){
if (count($this->_aMenuOptionsToReplace)) {
unset($this->_aMenuOptionsToReplace);
}
if(sizeof( $this->_aImportProcessCallbackFile )){
if (count($this->_aImportProcessCallbackFile)) {
unset($this->_aImportProcessCallbackFile);
}
if(sizeof( $this->_aOpenReassignCallback )){
if (count($this->_aOpenReassignCallback)) {
unset($this->_aOpenReassignCallback);
}
if (sizeof($this->_restExtendServices)) {
if (count($this->_restExtendServices)) {
$this->disableExtendsRestService($sNamespace);
}
//unregistering javascripts from this plugin
@@ -1365,20 +1365,23 @@ class PMPluginRegistry
/**
* Register a extend rest service class from a plugin to be served by processmaker
*
* @param string $sNamespace The namespace for the plugin
* @param string $namespace The namespace for the plugin
* @param string $className The service (api) class name
*/
public function registerExtendsRestService($sNamespace, $className)
public function registerExtendsRestService($namespace, $className)
{
$baseSrcPluginPath = PATH_PLUGINS . $sNamespace . PATH_SEP . "src";
$apiPath = PATH_SEP . "Services" . PATH_SEP . "Ext" . PATH_SEP;
$baseSrcPluginPath = PATH_PLUGINS . $namespace . 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
);
if (empty($this->_restExtendServices[$namespace])) {
$this->_restExtendServices[$namespace] = new stdClass();
}
$this->_restExtendServices[$namespace]->{$className} = [
'filePath' => $classFile,
'classParent' => $className,
'classExtend' => 'Ext' . $className
];
}
}
@@ -1391,9 +1394,9 @@ class PMPluginRegistry
public function getExtendsRestService($className)
{
$responseRestExtendService = array();
foreach ($this->_restExtendServices as $sNamespace => $restExtendService) {
if (isset($restExtendService[$className])) {
$responseRestExtendService = $restExtendService[$className];
foreach ($this->_restExtendServices as $namespace => $restExtendService) {
if (isset($restExtendService->{$className})) {
$responseRestExtendService = $restExtendService->{$className};
break;
}
}
@@ -1403,16 +1406,16 @@ class PMPluginRegistry
/**
* Remove a extend rest service class from a plugin to be served by processmaker
*
* @param string $sNamespace
* @param string $namespace
* @param string $className The service (api) class name
* @return bool
*/
public function disableExtendsRestService($sNamespace, $className = '')
public function disableExtendsRestService($namespace, $className = '')
{
if (isset($this->_restExtendServices[$sNamespace][$className]) && !empty($className)) {
unset($this->_restExtendServices[$sNamespace][$className]);
} elseif (empty($className)) {
unset($this->_restExtendServices[$sNamespace]);
if (empty($className)) {
unset($this->_restExtendServices[$namespace]);
} elseif (isset($this->_restExtendServices[$namespace]->{$className})) {
unset($this->_restExtendServices[$namespace]->{$className});
}
}
@@ -1673,7 +1676,7 @@ class PMPluginRegistry
public function getMenuOptionsToReplace($strMenuName)
{
$oMenuFromPlugin = $this->_aMenuOptionsToReplace;
if(sizeof($oMenuFromPlugin)) {
if (count($oMenuFromPlugin)) {
if (array_key_exists($strMenuName, $oMenuFromPlugin)) {
return $oMenuFromPlugin[$strMenuName];
}

View File

@@ -204,6 +204,7 @@ class PluginRegistry
}
Cache::pull(self::NAME_CACHE);
}
/**
* Get the plugin details, by filename
* @param string $Filename
@@ -1125,7 +1126,8 @@ class PluginRegistry
$ActionSave,
$ActionExecute,
$ActionGetFields
) {
)
{
$found = false;
/** @var CaseSchedulerPlugin $caseScheduler */
foreach ($this->_aCaseSchedulerPlugin as $caseScheduler) {
@@ -1245,15 +1247,18 @@ class PluginRegistry
*/
public function registerExtendsRestService($Namespace, $ClassName)
{
$baseSrcPluginPath = PATH_PLUGINS . $Namespace . PATH_SEP . "src";
$apiPath = PATH_SEP . "Services" . PATH_SEP . "Ext" . PATH_SEP;
$baseSrcPluginPath = PATH_PLUGINS . $Namespace . PATH_SEP . 'src';
$apiPath = PATH_SEP . 'Services' . PATH_SEP . 'Ext' . PATH_SEP;
$classFile = $baseSrcPluginPath . $apiPath . 'Ext' . $ClassName . '.php';
if (file_exists($classFile)) {
$this->_restExtendServices[$Namespace][$ClassName] = array(
"filePath" => $classFile,
"classParent" => $ClassName,
"classExtend" => 'Ext' . $ClassName
);
if (empty($this->_restExtendServices[$Namespace])) {
$this->_restExtendServices[$Namespace] = new stdClass();
}
$this->_restExtendServices[$Namespace]->{$ClassName} = [
'filePath' => $classFile,
'classParent' => $ClassName,
'classExtend' => 'Ext' . $ClassName
];
}
}
@@ -1264,10 +1269,10 @@ class PluginRegistry
*/
public function getExtendsRestService($ClassName)
{
$responseRestExtendService = array();
$responseRestExtendService = [];
foreach ($this->_restExtendServices as $Namespace => $restExtendService) {
if (isset($restExtendService[$ClassName])) {
$responseRestExtendService = $restExtendService[$ClassName];
if (isset($restExtendService->{$ClassName})) {
$responseRestExtendService = $restExtendService->{$ClassName};
break;
}
}
@@ -1282,10 +1287,10 @@ class PluginRegistry
*/
public function disableExtendsRestService($Namespace, $ClassName = '')
{
if (isset($this->_restExtendServices[$Namespace][$ClassName]) && !empty($ClassName)) {
unset($this->_restExtendServices[$Namespace][$ClassName]);
} elseif (empty($ClassName)) {
if (empty($ClassName)) {
unset($this->_restExtendServices[$Namespace]);
} elseif (isset($this->_restExtendServices[$Namespace]->{$ClassName})) {
unset($this->_restExtendServices[$Namespace]->{$ClassName});
}
}