/** * @param mixed $id * @return array|mixed */ public function get($id) { $processLog = $this->processLogFinder->getLoggedProcess($id); if ($processLog === null) { return $this->notFoundAction(); } $processLog['events'] = $this->convertToClientProcessEvents($this->processStreamReader->getStreamOfProcess($id)); $processDefinitions = $this->systemConfig->getProcessDefinitions(); if (!isset($processDefinitions[$processLog['start_message']])) { //@TODO: Provide better error, so that the client can show the user a message that config is missing return $this->notFoundAction(); } $processDefinition = $processDefinitions[$processLog['start_message']]; $processDefinition = ProcessToClientTranslator::translate($processLog['start_message'], $processDefinition, $this->systemConfig->getAllAvailableProcessingTypes(), $this->scriptLocation); $processLog['tasks'] = $processDefinition['tasks']; $this->populateTaskEvents($processLog); return ['log' => $processLog]; }
/** * @param Workflow $workflow * @throws \RuntimeException * @return void */ public function writeToProcessingConfig(Workflow $workflow) { $processNum = count($workflow->processList()); if ($processNum == 0) { $this->commandBus->dispatch(RemoveProcessConfig::ofProcessTriggeredByMessage($workflow->startMessage()->messageName(), $this->processingConfigLocation)); return; } $processDefinitions = $this->processingConfig->getProcessDefinitions(); if ($processNum == 1) { $processConfig = $this->translateToProcessingProcess($workflow->processList()[0]); $processConfig['name'] = $workflow->name(); if (isset($processDefinitions[$workflow->startMessage()->messageName()])) { $this->commandBus->dispatch(ChangeProcessConfig::ofProcessTriggeredByMessage($workflow->startMessage()->messageName(), $processConfig, $this->processingConfigLocation)); } else { $this->commandBus->dispatch(AddNewProcessToConfig::fromDefinition($processConfig['name'], $processConfig['process_type'], $workflow->startMessage()->messageName(), $processConfig['tasks'], $this->processingConfigLocation)); } } else { throw new \RuntimeException("Handling of more than process per workflow is not supported yet!"); } }
/** * @param array $processLog * @param ProcessingConfig $config * @param TranslatorInterface $translator */ public static function formatProcessLog(array &$processLog, ProcessingConfig $config, TranslatorInterface $translator) { $processDefinitions = $config->getProcessDefinitions(); self::addPrcessName($processLog, $processDefinitions, $translator); }