/** * {@inheritdoc} */ protected function migrateAggregateRoot($aggregateClassName, EventStream $eventStream, Version $aggregateVersion, Version $applicationVersion) { parent::migrateAggregateRoot($aggregateClassName, $eventStream, $aggregateVersion, $applicationVersion); // reconstruct the new aggregate root $aggregateRoot = call_user_func(array($aggregateClassName, 'loadFromHistory'), $eventStream); // create the snapshot $snapshot = new Snapshot($this->streamName($aggregateClassName), $aggregateRoot, new \DateTime()); // pserist the new snapshot $this->snapshotStore->persist($snapshot, $applicationVersion); }
/** * Save the aggregate snapshot. * * @param EventSourcedAggregateRootInterface $aggregateRoot */ protected function saveSnapshot(EventSourcedAggregateRootInterface $aggregateRoot) { $applicationVersion = VersionManager::currentApplicationVersion(); $snapshot = new Snapshot($this->streamName(), $aggregateRoot, new \DateTime()); $this->snapshotStore->persist($snapshot, $applicationVersion); }