public function knownWorkflows() { // // Default values. $out = array(); // // Global dependencies. global $WKFLDefaults; // // Retrieveing paths. $paths = Paths::Instance()->customPaths($WKFLDefaults[WKFL_DEFAULTS_PATHS][WKFL_DEFAULTS_PATH_WORKFLOWS], '*', Paths::ExtensionJSON, true); // // Generationg names list. foreach ($paths as $path) { $info = pathinfo($path); $out[] = $info['filename']; } sort($out); return $out; }
/** * This method loads current workflow's configuration. */ protected function load() { // // Avoiding multipe loads of configurations. if ($this->_config === false) { // // Checking log configuration $this->checkLog(); // // Logging operation start. $this->_log->log(LGGR_LOG_LEVEL_INFO, "Loading workflow '{$this->name()}'."); // // Reseting current stauts value. $this->_status = false; // // Global dependencies. global $WKFLDefaults; global $Defaults; // // Guessing names. $fileName = Names::SnakeFilename($this->name()); $this->_path = Paths::Instance()->customPaths($WKFLDefaults[WKFL_DEFAULTS_PATHS][WKFL_DEFAULTS_PATH_WORKFLOWS], $fileName, Paths::ExtensionJSON); // // Checking path existence. if ($this->_path && is_readable($this->_path)) { // // Loading configuration contents. $jsonString = file_get_contents($this->_path); // // Validating JSON strucutre. if (!$Defaults[GC_DEFAULTS_INSTALLED] && !self::GetValidator()->validate($jsonString, $info)) { $this->_log->log(LGGR_LOG_LEVEL_ERROR, "Workflow '{$this->name()}' specification is not well formed. {$info[JV_FIELD_ERROR][JV_FIELD_MESSAGE]}"); } else { // // Loading configuration. $this->_config = json_decode($jsonString); if ($this->_config) { $this->_status = true; } } } elseif (!$this->_path) { $this->_log->log(LGGR_LOG_LEVEL_ERROR, "Unknown workflow '{$this->name()}'."); } else { $this->_log->log(LGGR_LOG_LEVEL_ERROR, "Unable to read workflow path '{$this->_path}'."); } } }