private function generateEvents($manager, $entity, $id, $maxVersion) { for ($version = 1; $version <= $maxVersion; $version++) { $this->eventId++; $event = new EventDTO(); $event->setId($this->eventId); $event->setEventType('EventDouble'); $event->setEvent(new EventDouble($id)); $event->setEntityType($entity); $event->setEntityId($id->getId()); $event->setVersion($version); $event->setMetadata(array()); $event->setTime(new \DateTimeImmutable()); $this->addReference(sprintf('test-event-%s-%s-%s', $entity, $id->getId(), $version), $event); $manager->persist($event); } }
public function saveStream(EventStream $stream) { foreach ($stream as $message) { $this->checkVersion($message->getEntity()); $this->em->persist(EventDTO::fromEventMessage($message)); } $this->em->flush(); $this->em->clear(); }
public static function fromEventDTO(EventDTO $dto) { return new static($dto->getEntityType(), new Id($dto->getEntityId()), $dto->getVersion()); }
public static function fromEventDTO(EventDTO $dto) { return new static($dto->getEvent(), EntityDTO::fromEventDTO($dto), EventEnvelope::fromEventDTO($dto)); }
public static function fromEventDTO(EventDTO $dto) { return new static($dto->getId(), $dto->getTime(), $dto->getMetadata()); }