public function append(EventStream $events) { $streamName = $events->getName(); $events->each(function (DomainMessage $event) use($streamName) { $this->adapter->save($streamName, $event); }); }
/** * Replay past events * * @param EventStream $historyEvents * * @param null $version */ public function replay(EventStream $historyEvents, $version = null) { if (null !== $version) { $this->version = $version; } $historyEvents->each(function (DomainMessage $pastEvent) { $this->version = $pastEvent->getVersion(); $this->apply($pastEvent->getPayload()); }); }