Example #1
0
 /**
  * @param Event $event
  */
 public function on(Event $event)
 {
     $eventName = $event->getEventName();
     $this->logger->info('Handling event', ['event' => $eventName, 'handler' => get_class($this)]);
     $events = $this->storage->find($event->getIdentity()->getValue());
     var_dump($events);
 }
Example #2
0
 /**
  * @param Identity $identity
  * @param EventStorage $eventStorage
  * @param Serializer $serializer
  */
 private function prepareSomeEvents(Identity $identity, EventStorage $eventStorage, Serializer $serializer)
 {
     // This is not the preferred way, but used for simplicity! You should use commands to achieve this.
     $event = new CreatedEvent($identity);
     $event->setVersion(1);
     $eventStorage->append(EventDescriptor::record($identity->getValue(), 'aggregateType', $event->getEventName(), $serializer->serialize($event), $event->getVersion()));
     $event = new DemonstratedEvent($identity);
     $event->setVersion(2);
     $eventStorage->append(EventDescriptor::record($identity->getValue(), 'aggregateType', $event->getEventName(), $serializer->serialize($event), $event->getVersion()));
 }
Example #3
0
 /**
  * @return Identity[]
  */
 public function getAggregateIds() : array
 {
     return array_map(function (string $identity) : Identity {
         return Identity::fromString($identity);
     }, $this->storage->findIdentities());
 }