Files
luos/workflow/engine/classes/TriggerLibrary.php

150 lines
4.0 KiB
PHP
Raw Normal View History

2010-12-02 23:34:41 +00:00
<?php
2017-08-16 13:42:28 -04:00
use ProcessMaker\Plugins\PluginRegistry;
2012-10-09 13:26:07 -04:00
class TriggerLibrary
{
private $_aTriggerClasses_ = array();
private static $instance = null;
2012-10-09 13:26:07 -04:00
/**
* __construct
*
* @return void
*/
public function __construct()
2012-10-09 13:26:07 -04:00
{
//Initialize the Library and register the Default
$this->registerFunctionsFileToLibrary(PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions");
2012-10-09 13:26:07 -04:00
//Register all registered PLugin Functions
if (class_exists('folderData')) {
2017-08-01 12:16:06 -04:00
$oPluginRegistry = PluginRegistry::loadSingleton();
2012-10-09 13:26:07 -04:00
$aAvailablePmFunctions = $oPluginRegistry->getPmFunctions();
$oPluginRegistry->setupPlugins(); //Get and setup enabled plugins
2012-10-09 13:26:07 -04:00
foreach ($aAvailablePmFunctions as $key => $class) {
$filePlugin = PATH_PLUGINS . $class . PATH_SEP . 'classes' . PATH_SEP . 'class.pmFunctions.php';
if (file_exists($filePlugin) && !is_dir($filePlugin)) {
$this->registerFunctionsFileToLibrary($filePlugin, "ProcessMaker Functions");
2012-10-09 13:26:07 -04:00
}
}
}
//Add External Triggers
$dir = G::ExpandPath("classes") . 'triggers';
$filesArray = array();
if (file_exists($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !is_dir($dir . PATH_SEP . $file)) {
$this->registerFunctionsFileToLibrary($dir . PATH_SEP . $file, "ProcessMaker External Functions");
2012-10-09 13:26:07 -04:00
}
}
closedir($handle);
2012-10-09 13:26:07 -04:00
}
}
2012-10-09 13:26:07 -04:00
}
2010-12-02 23:34:41 +00:00
2012-10-09 13:26:07 -04:00
/**
* &getSingleton
*
* @return self::$instance;
*/
2022-09-20 11:02:57 -04:00
public static function &getSingleton()
2012-10-09 13:26:07 -04:00
{
if (self::$instance == null) {
self::$instance = new TriggerLibrary();
2012-10-09 13:26:07 -04:00
}
return self::$instance;
}
/**
* serializeInstance
*
* @return serialize ( self::$instance );
*/
public function serializeInstance()
2012-10-09 13:26:07 -04:00
{
return serialize(self::$instance);
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* unSerializeInstance
*
* @param integer $serialized
* @return void
*/
public function unSerializeInstance($serialized)
2012-10-09 13:26:07 -04:00
{
if (self::$instance == null) {
2017-08-10 12:10:42 -04:00
self::$instance = new PluginRegistry();
}
2012-10-09 13:26:07 -04:00
$instance = unserialize($serialized);
2012-10-09 13:26:07 -04:00
self::$instance = $instance;
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* registerFunctionsFileToLibrary
*
* @param string $filePath
* @param string $libraryName
* @return void
*/
public function registerFunctionsFileToLibrary($filePath, $libraryName)
2012-10-09 13:26:07 -04:00
{
$aLibrary = $this->getMethodsFromLibraryFile($filePath);
2012-10-09 13:26:07 -04:00
$aLibrary->libraryFile = $filePath;
$aLibrary->libraryName = $libraryName;
if (isset($aLibrary->info['className'])) {
2012-10-09 13:26:07 -04:00
$this->_aTriggerClasses_[$aLibrary->info['className']] = $aLibrary;
}
}
/**
* getMethodsFromLibraryFile
*
* @param string $file
* @return object(PHPClass) $parsedLibrary
*/
public function getMethodsFromLibraryFile($file)
2012-10-09 13:26:07 -04:00
{
// parse class comments from file
$parsedLibrary = new PHPClass();
$success = $parsedLibrary->parseFromFile($file);
2012-10-09 13:26:07 -04:00
return $parsedLibrary;
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* getRegisteredClasses
*
* @return array ($this->_aTriggerClasses_)
*/
public function getRegisteredClasses()
2012-10-09 13:26:07 -04:00
{
return ($this->_aTriggerClasses_);
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* getLibraryDefinition
*
* @param string $libraryClassName
* @return array ($this->_aTriggerClasses_[$libraryClassName])
*/
public function getLibraryDefinition($libraryClassName)
2012-10-09 13:26:07 -04:00
{
return ($this->_aTriggerClasses_[$libraryClassName]);
2010-12-02 23:34:41 +00:00
}
2012-10-09 13:26:07 -04:00
/**
* __destruct
*
* @return void
*/
public function __destruct()
2012-10-09 13:26:07 -04:00
{
//TODO - Insert your code here
}
2010-12-02 23:34:41 +00:00
}