Prooph\EventStore\Snapshot\SnapshotStore::save PHP Method

save() public method

Save aggregate root
public save ( Snapshot $snapshot ) : void
$snapshot Snapshot
return void
    public function save(Snapshot $snapshot)
    {
        $this->adapter->save($snapshot);
    }

Usage Example

コード例 #1
0
ファイル: Snapshotter.php プロジェクト: prooph/snapshotter
 /**
  * @param TakeSnapshot $command
  * @throws Exception\RuntimeException
  */
 public function __invoke(TakeSnapshot $command)
 {
     $aggregateType = $command->aggregateType();
     if (!isset($this->aggregateRepositories[$aggregateType])) {
         throw new Exception\RuntimeException(sprintf('No repository for aggregate type %s configured', $command->aggregateType()));
     }
     $repository = $this->aggregateRepositories[$aggregateType];
     $aggregateRoot = $repository->getAggregateRoot($command->aggregateId());
     if (null === $aggregateRoot) {
         throw new RuntimeException(sprintf('Could not find aggregate root %s with id %s', $aggregateType, $command->aggregateId()));
     }
     $this->snapshotStore->save(new Snapshot(AggregateType::fromAggregateRootClass($aggregateType), $command->aggregateId(), $aggregateRoot, $repository->extractAggregateVersion($aggregateRoot), $command->createdAt()));
 }
All Usage Examples Of Prooph\EventStore\Snapshot\SnapshotStore::save