コード例 #1
0
 /**
  * @param string $filename
  * @param Prototype $prototype
  * @param array $metadata
  * @return mixed
  */
 public function readDataForType($filename, Prototype $prototype, array &$metadata = [])
 {
     $content = file_get_contents($filename);
     $data = json_decode($content, true);
     $typeClass = $prototype->of();
     $type = $typeClass::fromJsonDecodedData($data);
     return $type->value();
 }
コード例 #2
0
 /**
  * @param TaskId $taskId
  * @param TaskType $taskType
  * @param MessageHandler $messageHandler
  * @param Prototype $processingType
  * @param ProcessingMetadata $metadata
  * @return TaskWasSetUp
  */
 public static function with(TaskId $taskId, TaskType $taskType, MessageHandler $messageHandler, Prototype $processingType, ProcessingMetadata $metadata)
 {
     $event = self::occur($taskId->toString(), ['task_type' => $taskType->toString(), 'message_handler_id' => $messageHandler->messageHandlerId()->toString(), 'processing_type' => $processingType->of(), 'task_metadata' => $metadata->toArray()]);
     $event->taskId = $taskId;
     $event->taskType = $taskType;
     $event->messageHandlerId = $messageHandler->messageHandlerId();
     $event->processingType = $processingType;
     $event->taskMetadata = $metadata;
     return $event;
 }
コード例 #3
0
 /**
  * @param MessageHandlerId $messageHandlerId
  * @param string $handlerName
  * @param NodeName $processingNodeName
  * @param HandlerType $handlerType
  * @param DataDirection $dataDirection
  * @param ProcessingTypes $processingTypes
  * @param ProcessingMetadata $processingMetadata
  * @param string $metadataRiotTag
  * @param string $icon
  * @param string $iconType
  * @param Prototype $preferredProcessingType
  * @param ProcessingId $processingId
  * @param array $additionalData
  * @return MessageHandlerWasInstalled
  */
 public static function record(MessageHandlerId $messageHandlerId, $handlerName, NodeName $processingNodeName, HandlerType $handlerType, DataDirection $dataDirection, ProcessingTypes $processingTypes, ProcessingMetadata $processingMetadata, $metadataRiotTag, $icon, $iconType, Prototype $preferredProcessingType = null, ProcessingId $processingId = null, array $additionalData = [])
 {
     $event = self::occur($messageHandlerId->toString(), ['name' => $handlerName, 'processing_node_name' => $processingNodeName->toString(), 'handler_type' => $handlerType->toString(), 'data_direction' => $dataDirection->toString(), 'supported_processing_types' => $processingTypes->toArray(), 'processing_metadata' => $processingMetadata->toArray(), 'metadata_riot_tag' => $metadataRiotTag, 'icon' => $icon, 'icon_type' => $iconType, 'preferred_processing_type' => $preferredProcessingType ? $preferredProcessingType->of() : null, 'processing_id' => $processingId ? $processingId->toString() : null, 'additional_data' => $additionalData]);
     $event->messageHandlerId = $messageHandlerId;
     $event->processingNodeName = $processingNodeName;
     $event->handlerType = $handlerType;
     $event->dataDirection = $dataDirection;
     $event->supportedProcessingTypes = $processingTypes;
     $event->processingMetadata = $processingMetadata;
     $event->preferredProcessingType = $preferredProcessingType;
     $event->processingId = $processingId;
     return $event;
 }
コード例 #4
0
ファイル: WorkflowMessage.php プロジェクト: prooph/processing
 /**
  * @param Prototype $aPrototype
  * @param string|NodeName $origin
  * @param string|NodeName $target
  * @param array $metadata
  * @return WorkflowMessage
  */
 public static function collectDataOf(Prototype $aPrototype, $origin, $target, array $metadata = [])
 {
     $messageName = MessageNameUtils::getCollectDataCommandName($aPrototype->of());
     return new static(Payload::fromPrototype($aPrototype), $messageName, $origin, $target, $metadata);
 }
コード例 #5
0
 /**
  * @param Prototype $prototype
  * @return bool
  */
 public function isSupported(Prototype $prototype)
 {
     if ($this->supportAllTypes) {
         return true;
     }
     foreach ($this->supportedProcessingTypes as $processingType) {
         if ($processingType->of() === $prototype->of()) {
             return true;
         }
     }
     return false;
 }
コード例 #6
0
 /**
  * @param string $message
  * @param Prototype $prototype
  * @return static
  */
 public static function fromMessageAndPrototype($message, Prototype $prototype)
 {
     $invalidTypeException = new static('[' . $prototype->of() . ']: ' . $message);
     $invalidTypeException->relatedPrototypeOfType = $prototype;
     return $invalidTypeException;
 }
コード例 #7
0
ファイル: Payload.php プロジェクト: prooph/processing
 /**
  * @param Prototype $aPrototype
  * @return Payload
  */
 public static function fromPrototype(Prototype $aPrototype)
 {
     return new static($aPrototype->of(), null);
 }
コード例 #8
0
 /**
  * @param array $csvRow
  * @param Prototype $itemPrototype
  * @throws \InvalidArgumentException
  */
 protected function convertToItemData(array $csvRow, Prototype $itemPrototype)
 {
     $itemProperties = $itemPrototype->typeProperties();
     foreach ($csvRow as $propertyName => $propertyValue) {
         if (!isset($itemProperties[$propertyName])) {
             throw new \InvalidArgumentException(sprintf('Csv row property %s is not a known item property. Valid properties are %s', $propertyName, implode(', ', array_keys($itemProperties))));
         }
         $propertyType = $itemProperties[$propertyName]->typePrototype()->of();
         $csvRow[$propertyName] = $propertyType::fromString((string) $csvRow[$propertyName]);
     }
     $itemType = $itemPrototype->of();
     return $itemType::fromNativeValue($csvRow);
 }