/** * @param $startMessage * @param array $processDefinition * @param array $knownProcessingTypes * @param ScriptLocation $scriptLocation * @return array */ public static function translate($startMessage, array $processDefinition, array $knownProcessingTypes, ScriptLocation $scriptLocation) { $messageType = MessageNameUtils::getMessageSuffix($startMessage); foreach ($processDefinition['tasks'] as $i => &$task) { $task['id'] = $i; } return ['id' => $startMessage, 'name' => $processDefinition['name'], 'process_type' => $processDefinition['process_type'], 'start_message' => ['message_type' => $messageType, 'processing_type' => ProcessingTypeClass::extractFromMessageName($startMessage, $knownProcessingTypes)], 'tasks' => array_map(function ($task) use($scriptLocation) { if ($task['task_type'] === Definition::TASK_MANIPULATE_PAYLOAD) { $task['manipulation_script'] = str_replace($scriptLocation->toString() . DIRECTORY_SEPARATOR, "", $task['manipulation_script']); } return $task; }, $processDefinition['tasks'])]; }
/** * @param string $messageName * @param array $availableProcessingTypes * @throws \InvalidArgumentException */ private function assertMessageName($messageName, array $availableProcessingTypes) { if (!is_string($messageName)) { throw new \InvalidArgumentException('Message name must be a string'); } if (!MessageNameUtils::isWorkflowMessage($messageName)) { throw new \InvalidArgumentException(sprintf('Message name format -%s- is not valid', $messageName)); } ProcessingTypeClass::extractFromMessageName($messageName, $availableProcessingTypes); }