/**
  * Appends an event to the event store
  */
 private function appendEvent(DomainMessage $event)
 {
     $this->connection->table($this->table)->insert(['uuid' => (string) $event->getId(), 'playhead' => (int) $event->getPlayhead(), 'metadata' => $this->serialize($event->getMetadata()), 'payload' => $this->serialize($event->getPayload()), 'recorded_on' => $event->getRecordedOn()->toString(), 'type' => $event->getType()]);
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param DomainMessage $domainMessage
  */
 private function interactOnDomainMessage(InputInterface $input, OutputInterface $output, DomainMessage $domainMessage)
 {
     $metadata = "";
     $payload = "";
     $reflector = new DomainMessageReflector($domainMessage);
     $questionHelper = new QuestionHelper();
     $question = new ConfirmationQuestion('Continue to next playhead? (Y/n)', true);
     $reflections = $reflector->reflect(DomainMessageReflector::METADATA);
     foreach ($reflections as $property => $value) {
         $metadata = $metadata . $property . ': ' . $value . " ";
     }
     $reflections = $reflector->reflect(DomainMessageReflector::PAYLOAD);
     foreach ($reflections as $property => $value) {
         $payload = $payload . $property . ': ' . $value . " ";
     }
     $table = new Table($output);
     $table->setHeaders(array("Property", "Value"))->setRows(array(array("Id", $domainMessage->getId()), array("Recorded at", $domainMessage->getRecordedOn()->toString()), array("Playhead number", $domainMessage->getPlayhead()), array("Command", $domainMessage->getType())))->render();
     $table = new Table($output);
     $table->setHeaders(array("Metadata"))->setRows(array(array($metadata)))->render();
     $table = new Table($output);
     $table->setHeaders(array("Payload"))->setRows(array(array($payload)))->render();
     if (false === $questionHelper->ask($input, $output, $question)) {
         exit("replaying stopped");
     }
 }
示例#3
0
 /**
  * Determine if a domain message is matched by this criteria
  *
  * @param DomainMessage $domainMessage
  * @return bool
  */
 public function isMatchedBy(DomainMessage $domainMessage)
 {
     if ($this->aggregateRootTypes) {
         throw new CriteriaNotSupportedException('Cannot match criteria based on aggregate root types.');
     }
     if ($this->aggregateRootIds && !in_array($domainMessage->getId(), $this->aggregateRootIds)) {
         return false;
     }
     if ($this->eventTypes && !in_array($domainMessage->getType(), $this->eventTypes)) {
         return false;
     }
     return true;
 }
示例#4
0
 private function insertMessage(Connection $connection, DomainMessage $domainMessage)
 {
     $data = array('uuid' => $this->convertIdentifierToStorageValue((string) $domainMessage->getId()), 'playhead' => $domainMessage->getPlayhead(), 'metadata' => json_encode($this->metadataSerializer->serialize($domainMessage->getMetadata())), 'payload' => json_encode($this->payloadSerializer->serialize($domainMessage->getPayload())), 'recorded_on' => $domainMessage->getRecordedOn()->toString(), 'type' => $domainMessage->getType());
     $connection->insert($this->tableName, $data);
 }
 /**
  * Turns a DomainMessage into array using broadway's serializers.
  *
  * @param DomainMessage $message The domain message.
  * @throws SerializationException When the serializers cannot perform.
  * @return array                  An array representation of the message.
  */
 private function convertDomainMessage(DomainMessage $message)
 {
     $metadata = $this->metadataSerializer->serialize($message->getMetadata());
     $payload = $this->payloadSerializer->serialize($message->getPayload());
     return ['uuid' => (string) $message->getId(), 'playhead' => $message->getPlayhead(), 'metadata' => json_encode($metadata), 'payload' => json_encode($payload), 'recorded_on' => $message->getRecordedOn()->toString(), 'type' => $message->getType()];
 }