/**
  * {@inheritdoc}
  */
 public function persist(Snapshot $snapshot, Version $applicationVersion)
 {
     $applicationKey = $this->getApplicationKey($applicationVersion);
     if (!$this->store->containsKey($applicationKey)) {
         $this->store->set($applicationKey, new ArrayHashMap());
     }
     /** @var ArrayHashMap $applicationCollection */
     $applicationCollection = $this->store->get($applicationKey);
     $aggregateKey = $this->getAggregateKey($snapshot->aggregateType(), $snapshot->version());
     if (!$applicationCollection->containsKey($aggregateKey)) {
         $applicationCollection->set($aggregateKey, new ArrayHashMap());
     }
     /** @var ArrayHashMap $aggregateCollection */
     $aggregateCollection = $applicationCollection->get($aggregateKey);
     $aggregateCollection->set($snapshot->aggregateId()->toNative(), $snapshot);
 }
Example #2
0
 /**
  * Test AggregateType method.
  */
 public function testAggregateType()
 {
     $this->given($post = PostEventSourcedFactory::create($this->faker->sentence, $this->faker->paragraph))->and($snapshot = new Snapshot('posts', $post, new \DateTime()))->then()->string($snapshot->aggregateType())->isEqualTo('posts');
 }