/** * Save aggregate root * * @param Snapshot $snapshot * @return void */ public function save(Snapshot $snapshot) { $this->adapter->save($snapshot); }
/** * @param TakeSnapshot $command */ public function __invoke(TakeSnapshot $command) { $repository = $this->aggregateRepositories[$command->aggregateType()]; $aggregateRoot = $repository->getAggregateRoot($command->aggregateId()); $this->snapshotAdapter->add(new Snapshot(AggregateType::fromAggregateRootClass($command->aggregateType()), $command->aggregateId(), $aggregateRoot, $command->version(), $command->createdAt())); }