예제 #1
0
 /**
  * @param DomainEvent $event
  * @param EventHandlerInterface $eventHandler
  */
 protected function queueEvent(DomainEvent $event, EventHandlerInterface $eventHandler)
 {
     $serializedEvent = $this->arraySerializer->serialize($event);
     $recipient = get_class($eventHandler);
     $this->queue->queue(new Message($recipient, $serializedEvent));
     $this->emitEventQueueingSuccess($event, $eventHandler);
 }
예제 #2
0
 /**
  * @param Message $message
  * @return void
  */
 public function queue(Message $message)
 {
     /** @var EventHandlerInterface $handler */
     $handler = $this->objectManager->get($message->getRecipient());
     $event = $this->arraySerializer->unserialize($message->getPayload());
     $handler->handle($event);
 }
예제 #3
0
 /**
  * @param string $serializedMessage
  * @return Message
  */
 public function unserialize($serializedMessage)
 {
     if (is_string($serializedMessage) === FALSE) {
         throw new \InvalidArgumentException('The JsonSerializer can only unserialize strings.', 1427369767);
     }
     return $this->arraySerializer->unserialize(json_decode($serializedMessage, TRUE));
 }
예제 #4
0
 /**
  * @param Command $command
  * @return array
  */
 protected function getCommandData(Command $command)
 {
     return $this->commandSerializer->serialize($command);
 }
예제 #5
0
 /**
  * @param DomainEvent $event
  * @return array
  */
 protected function getEventData(DomainEvent $event)
 {
     return $this->commandSerializer->serialize($event);
 }
 /**
  * @param Event $event
  * @param string $eventType
  * @return DomainEvent
  * @throws IncompatibleModelException
  */
 public function fromEvent(Event $event, $eventType)
 {
     $data = $event->getData();
     return $this->arraySerializer->unserialize(['messageType' => $eventType, 'payload' => $data]);
 }