This commit is contained in:
Marco Antonio Nina Mena
2018-03-15 16:35:53 -04:00
committed by Paula Quispe
parent c480a8b65e
commit 937e40d6d1
13 changed files with 155 additions and 38 deletions

View File

@@ -90,6 +90,7 @@ class PluginAdapter
'_aJavascripts' => ['name' => 'PLUGIN_JS', 'type' => 'array'],
'_aJs' => ['name' => 'PLUGIN_JS', 'type' => 'array'],
'_restServices' => ['name' => 'PLUGIN_REST_SERVICE', 'type' => 'array'],
'_aCronFiles' => ['name' => 'PLUGIN_CRON_FILES', 'type' => 'array'],
'_aTaskExtendedProperties' => ['name' => 'PLUGIN_TASK_EXTENDED_PROPERTIES', 'type' => 'array'],
];

View File

@@ -53,4 +53,24 @@ class CronFile
{
return $CronFile == $this->CronFile;
}
/**
* Get plugin name
*
* @return string
*/
public function getNamespace()
{
return $this->Namespace;
}
/**
* Get Cron file
*
* @return string
*/
public function getCronFile()
{
return $this->CronFile;
}
}

View File

@@ -1355,22 +1355,23 @@ class PluginRegistry
/**
* Register a cron file
* @param string $Namespace Name of Plugin
* @param string $CronFile
* @param string $pluginName Name of Plugin
* @param string $cronFileToRegister
*/
public function registerCronFile($Namespace, $CronFile)
public function registerCronFile($pluginName, $cronFileToRegister)
{
$found = false;
/** @var CronFile $cronFile */
foreach ($this->_aCronFiles as $cronFile) {
if ($cronFile->equalCronFileTo($CronFile) && $cronFile->equalNamespaceTo($Namespace)) {
$cronFile->setCronFile($CronFile);
if ($cronFile instanceof CronFile &&
$cronFile->equalNamespaceTo($pluginName) &&
$cronFile->equalCronFileTo($cronFileToRegister)) {
$cronFile->setCronFile($cronFileToRegister);
$found = true;
}
}
if (!$found) {
$CronFile = new CronFile($Namespace, $CronFile);
$this->_aCronFiles[] = $CronFile;
$this->_aCronFiles[] = new CronFile($pluginName, $cronFileToRegister);
}
}

View File

@@ -5,6 +5,7 @@ namespace ProcessMaker\Plugins\Traits;
use BasePeer;
use G;
use PluginsRegistry;
use ProcessMaker\Plugins\Interfaces\CronFile;
use ProcessMaker\Plugins\Interfaces\CssFile;
use ProcessMaker\Plugins\Interfaces\FolderDetail;
use ProcessMaker\Plugins\Interfaces\JsFile;
@@ -116,6 +117,7 @@ trait PluginStructure
$this->buildCss(G::json_decode($plugin['PluginCss'], true));
$this->buildJs(G::json_decode($plugin['PluginJs'], true));
$this->buildRestService(G::json_decode($plugin['PluginRestService'], true));
$this->buildCronFiles($plugin['PluginNamespace'], G::json_decode($plugin['PluginCronFiles'], true));
$this->buildAttributes($plugin['PluginNamespace'], G::json_decode($plugin['PluginAttributes']));
}
}
@@ -261,6 +263,23 @@ trait PluginStructure
$this->_restServices = array_merge($this->_restServices, $restServices);
}
/**
* Builds an array with the Cron Files configurations and set to the respective attribute
*
* @param string $pluginName
* @param array $cronFilesToAdd
*/
private function buildCronFiles($pluginName, $cronFilesToAdd)
{
$cronFiles = [];
if ($cronFilesToAdd) {
foreach ($cronFilesToAdd as $cronFile) {
$cronFiles[] = new CronFile($pluginName, $cronFile['CronFile']);
}
}
$this->_aCronFiles = array_merge($this->_aCronFiles, $cronFiles);
}
/**
* Build other properties that are not considered in the schema of the table
* @param string $namespace