Merged in bugfix/HOR-3275 (pull request #5682)

HOR-3275

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Roly
2017-05-25 17:05:42 +00:00
committed by Julio Cesar Laura Avendaño
5 changed files with 129 additions and 63 deletions

View File

@@ -520,7 +520,7 @@ class PMPlugin
* @param string $workspace
* @return array
*/
public static function getList($workspace)
public static function getListPluginsManager($workspace)
{
$items = Array();
$aPluginsPP = array();
@@ -576,6 +576,34 @@ class PMPlugin
}
return $items;
}
/**
* Gets a general list of all plugins within processmaker per workspace.
*
* @param string $workspace
* @return array
*/
public static function getListAllPlugins($workspace)
{
PMPluginRegistry::saveState();
$pathSingleton = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP . "plugin.singleton";
$oPluginRegistry = PMPluginRegistry::loadSingleton($pathSingleton);
$items = [];
if ($handle = opendir(PATH_PLUGINS)) {
while (false !== ($file = readdir($handle))) {
if (strpos($file, '.php', 1) && is_file(PATH_PLUGINS . $file)) {
include_once (PATH_PLUGINS . $file);
$detail = $oPluginRegistry->getPluginDetails($file);
if ($detail !== null) {
$items[] = $detail;
}
}
}
closedir($handle);
}
PMPluginRegistry::restoreState();
return $items;
}
}

View File

@@ -122,6 +122,7 @@ class PMPluginRegistry
private $_restServiceEnabled = array();
private static $instance = null;
private static $stateSaved = null;
/**
* This function is the constructor of the PMPluginRegistry class
@@ -1946,4 +1947,28 @@ class PMPluginRegistry
}
}
/**
* Saves the state of instance, in the private property 'stateSaved'.
* Use the 'restoreState()' method to put the instance in the saved state.
*/
public static function saveState()
{
$pluginRegistry = PMPluginRegistry::getSingleton();
self::$stateSaved = $pluginRegistry->serializeInstance();
}
/**
* Restores the state of the instance that is in the private variable 'stateSaved'.
* You must save the state of the instacia with the method 'saveState()'
* before being called.
*/
public static function restoreState()
{
if (self::$stateSaved !== null) {
$pluginRegistry = PMPluginRegistry::getSingleton();
self::$instance = $pluginRegistry->unSerializeInstance(self::$stateSaved);
self::$stateSaved = null;
}
}
}