createdAt() 공개 메소드

public createdAt ( ) : DateTimeImmutable
리턴 DateTimeImmutable
 /**
  * Save a snapshot
  *
  * @param Snapshot $snapshot
  * @return void
  */
 public function save(Snapshot $snapshot)
 {
     $table = $this->getTable($snapshot->aggregateType());
     $this->connection->insert($table, ['aggregate_type' => $snapshot->aggregateType()->toString(), 'aggregate_id' => $snapshot->aggregateId(), 'last_version' => $snapshot->lastVersion(), 'created_at' => $snapshot->createdAt()->format('Y-m-d\\TH:i:s.u'), 'aggregate_root' => serialize($snapshot->aggregateRoot())], ['string', 'string', 'integer', 'string', 'blob']);
     $queryBuilder = $this->connection->createQueryBuilder();
     $table = $this->getTable($snapshot->aggregateType());
     $queryBuilder->delete($table)->where('aggregate_type = :aggregate_type')->andWhere('aggregate_id = :aggregate_id')->andWhere('last_version < :last_version')->setParameter('aggregate_type', $snapshot->aggregateType()->toString())->setParameter('aggregate_id', $snapshot->aggregateId())->setParameter('last_version', $snapshot->lastVersion());
     $queryBuilder->execute();
 }
 /**
  * Save a snapshot
  *
  * @param Snapshot $snapshot
  * @return void
  */
 public function save(Snapshot $snapshot)
 {
     $key = $this->getShortAggregateTypeName($snapshot->aggregateType()) . '_' . $snapshot->aggregateId();
     $data = ['aggregate_root' => serialize($snapshot->aggregateRoot()), 'aggregate_type' => $snapshot->aggregateType()->toString(), 'aggregate_id' => $snapshot->aggregateId(), 'last_version' => $snapshot->lastVersion(), 'created_at' => $snapshot->createdAt()->format('U.u')];
     $this->memcached->set($key, $data);
 }
 /**
  * Add a snapshot
  *
  * @param Snapshot $snapshot
  * @return void
  */
 public function add(Snapshot $snapshot)
 {
     $table = $this->getTable($snapshot->aggregateType());
     $this->connection->insert($table, ['aggregate_type' => $snapshot->aggregateType()->toString(), 'aggregate_id' => $snapshot->aggregateId(), 'last_version' => $snapshot->lastVersion(), 'created_at' => $snapshot->createdAt()->format('Y-m-d\\TH:i:s.u'), 'aggregate_root' => serialize($snapshot->aggregateRoot())], ['string', 'string', 'integer', 'string', 'blob']);
 }
 /**
  * Save a snapshot
  *
  * @param Snapshot $snapshot
  * @return void
  */
 public function save(Snapshot $snapshot)
 {
     $gridFs = $this->getGridFs($snapshot->aggregateType());
     $createdAt = new \MongoDate($snapshot->createdAt()->getTimestamp(), $snapshot->createdAt()->format('u'));
     $gridFs->storeBytes(serialize($snapshot->aggregateRoot()), ['aggregate_type' => $snapshot->aggregateType()->toString(), 'aggregate_id' => $snapshot->aggregateId(), 'last_version' => $snapshot->lastVersion(), 'created_at' => $createdAt], $this->writeConcern);
     $gridFs->remove(['aggregate_type' => $snapshot->aggregateType()->toString(), 'aggregate_id' => $snapshot->aggregateId(), 'last_version' => ['$lt' => $snapshot->lastVersion()]], $this->writeConcern);
     $gridFs->remove(['aggregate_type' => $snapshot->aggregateType()->toString(), 'aggregate_id' => $snapshot->aggregateId(), 'last_version' => $snapshot->lastVersion(), 'created_at' => ['$lt' => $createdAt]], $this->writeConcern);
 }
 /**
  * @test
  */
 public function it_uses_snapshot_store()
 {
     $this->prepareSnapshotStoreAggregateRepository();
     $this->eventStore->beginTransaction();
     $user = User::create('John Doe', '*****@*****.**');
     $this->repository->addAggregateRoot($user);
     $this->eventStore->commit();
     $now = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
     $snapshot = new Snapshot(AggregateType::fromAggregateRootClass('ProophTest\\EventStore\\Mock\\User'), $user->getId()->toString(), $user, 1, $now);
     // short getter assertion
     $this->assertSame($now, $snapshot->createdAt());
     $this->snapshotStore->save($snapshot);
     $loadedEvents = [];
     $this->eventStore->getActionEventEmitter()->attachListener('loadEventsByMetadataFrom.post', function (ActionEvent $event) use(&$loadedEvents) {
         foreach ($event->getParam('streamEvents', []) as $streamEvent) {
             $loadedEvents[] = $streamEvent;
         }
     });
     $this->repository->getAggregateRoot($user->getId()->toString());
     $this->assertEmpty($loadedEvents);
 }