up observations

This commit is contained in:
Ronald Quenta
2017-08-04 09:32:25 -04:00
parent 6ca19b77c9
commit 651d22a71d
32 changed files with 145 additions and 82 deletions

View File

@@ -61,12 +61,26 @@ class PluginRegistry
*/
public static function loadSingleton()
{
if (self::$instance == null) {
if (self::$instance === null) {
self::$instance = new PluginRegistry();
}
return self::$instance;
}
/**
* Load the singleton instance from a serialized stored file
* @return PluginRegistry
* @throws Exception
*/
public static function newInstance()
{
self::$instance = new PluginRegistry();
if (! is_object(self::$instance) || get_class(self::$instance) != "ProcessMaker\Plugins\PluginRegistry") {
throw new Exception("Can't load main PluginRegistry object.");
}
return self::$instance;
}
/**
* Register the plugin in the singleton
* @param string $Namespace Name Plugin
@@ -113,7 +127,8 @@ class PluginRegistry
if ($pluginDetail->isEnabled()) {
if (!empty($pluginDetail->getFile()) && file_exists($pluginDetail->getFile())) {
$arrayFileInfo = pathinfo($pluginDetail->getFile());
$Filename = (($pluginDetail->getNamespace() == "enterprise") ?
$Filename = (
($pluginDetail->getNamespace() == "enterprise") ?
PATH_CORE . "methods" . PATH_SEP . "enterprise" . PATH_SEP :
PATH_PLUGINS
) . $arrayFileInfo["basename"];
@@ -403,7 +418,6 @@ class PluginRegistry
$pluginRegistry->savePlugin($value);
}
}
}
}
@@ -840,7 +854,6 @@ class PluginRegistry
$found = true;
}
}
}
}
return $found;

View File

@@ -43,13 +43,13 @@ trait PluginStructure
private $_restServices = array();
/** @var array Reports added */
private $_aReports = array();
/** @var array */
/** @var array */
private $_aDashboardPages = array();
/** @var array Dashlets added */
private $_aDashlets = array();
/** @var array Toolbar file added */
private $_aToolbarFiles = array();
/** @var array Case Scheduler added */
/** @var array Case Scheduler added */
private $_aCaseSchedulerPlugin = array();
/** @var array Task Extended added */
private $_aTaskExtendedProperties = array();
@@ -248,9 +248,7 @@ trait PluginStructure
*/
private function buildRestService($restServices)
{
foreach ($restServices as $restService) {
$this->_restServices = array_merge($this->_restServices, $restService);
}
$this->_restServices = array_merge($this->_restServices, $restServices);
}
/**
@@ -264,7 +262,7 @@ trait PluginStructure
foreach ($attributes as $key => $value) {
$this->_aPlugins[$namespace]->{$key} = $value;
if (property_exists($this, $key)) {
$this->{$key} = array_merge($this->{$key}, $value);
$this->{$key} = array_merge($this->{$key}, (array)$value);
}
}
}
@@ -288,8 +286,7 @@ trait PluginStructure
foreach ($PluginRegistry as $propertyName => $propertyValue) {
foreach ($propertyValue as $key => $plugin) {
if (is_object($plugin) &&
((property_exists($plugin, 'Namespace') && $plugin->equalNamespaceTo($Namespace)) ||
(!is_int($key) && $key == $Namespace))
property_exists($plugin, 'Namespace') && $plugin->equalNamespaceTo($Namespace)
) {
$newStructurePlugin[$propertyName][] = $plugin;
} elseif (is_object($plugin) &&
@@ -297,6 +294,8 @@ trait PluginStructure
$plugin->pluginName == $Namespace
) {
$newStructurePlugin[$propertyName][] = $plugin;
} elseif (is_string($key) && $key == $Namespace) {
$newStructurePlugin[$propertyName][$key] = $plugin;
} elseif (is_string($plugin) && $plugin == $Namespace) {
$newStructurePlugin[$propertyName][] = $plugin;
}