public function create($data) { if (!array_key_exists('name', $data)) { return $this->apiProblem(422, "No name given for the message handler"); } if (!array_key_exists('node_name', $data)) { return $this->apiProblem(422, "No node_name given for the message handler"); } if (!array_key_exists('type', $data)) { return $this->apiProblem(422, "No type given for the message handler"); } if (!array_key_exists('data_direction', $data)) { return $this->apiProblem(422, "No data_direction given for the message handler"); } if (!array_key_exists('metadata_riot_tag', $data)) { return $this->apiProblem(422, "No metadata_riot_tag given for the message handler"); } if (!array_key_exists('icon', $data)) { return $this->apiProblem(422, "No icon given for the message handler"); } if (!array_key_exists('icon_type', $data)) { return $this->apiProblem(422, "No icon_type given for the message handler"); } if (!isset($data['processing_types'])) { $data['processing_types'] = ProcessingTypes::SUPPORT_ALL; } if (!isset($data['processing_metadata'])) { $data['processing_metadata'] = ProcessingMetadata::noData()->toArray(); } if (!isset($data['preferred_type'])) { $data['preferred_type'] = null; } if (!isset($data['processing_id'])) { $data['processing_id'] = null; } if (!isset($data['additional_data'])) { $data['additional_data'] = []; } $messageHandlerId = MessageHandlerId::generate(); $this->commandBus->dispatch(InstallMessageHandler::withData($messageHandlerId, $data['name'], $data['node_name'], $data['type'], $data['data_direction'], $data['processing_types'], $data['processing_metadata'], $data['metadata_riot_tag'], $data['icon'], $data['icon_type'], $data['preferred_type'], $data['processing_id'], $data['additional_data'])); return $this->location($this->url()->fromRoute('prooph.link/process_config/api/message_handler', ['id' => $messageHandlerId->toString()])); }
/** * @param InstallMessageHandler $command */ public function handle(InstallMessageHandler $command) { $node = $this->processingNodeList->getNode($command->nodeName()); $handler = $node->installMessageHandler($command->messageHandlerId(), $command->messageHandlerName(), $command->handlerType(), $command->dataDirection(), $command->supportedProcessingTypes(), $command->processingMetadata(), $command->metadataRiotTag(), $command->icon(), $command->iconType(), $command->preferredProcessingType(), $command->handlerProcessingId(), $command->additionalData()); $this->messageHandlerCollection->add($handler); }