reconstituteAggregateFromHistory() public method

public reconstituteAggregateFromHistory ( AggregateType $aggregateType, Iterator $historyEvents ) : object
$aggregateType AggregateType
$historyEvents Iterator
return object reconstructed EventSourcedAggregateRoot
 /**
  * Returns null if no stream events can be found for aggregate root otherwise the reconstituted aggregate root
  *
  * @param string $aggregateId
  * @return null|object
  */
 public function getAggregateRoot($aggregateId)
 {
     Assertion::string($aggregateId, 'AggregateId needs to be string');
     if ($this->snapshotStore) {
         $eventSourcedAggregateRoot = $this->loadFromSnapshotStore($aggregateId);
         if ($eventSourcedAggregateRoot) {
             //Cache aggregate root in the identity map
             $this->identityMap[$aggregateId] = $eventSourcedAggregateRoot;
             return $eventSourcedAggregateRoot;
         }
     }
     $streamName = $this->determineStreamName($aggregateId);
     $streamEvents = null;
     if ($this->oneStreamPerAggregate) {
         $streamEvents = $this->eventStore->load($streamName)->streamEvents();
     } else {
         $streamEvents = $this->eventStore->loadEventsByMetadataFrom($streamName, ['aggregate_type' => $this->aggregateType->toString(), 'aggregate_id' => $aggregateId]);
     }
     if (!$streamEvents->valid()) {
         return;
     }
     $eventSourcedAggregateRoot = $this->aggregateTranslator->reconstituteAggregateFromHistory($this->aggregateType, $streamEvents);
     //Cache aggregate root in the identity map but without pending events
     $this->identityMap[$aggregateId] = $eventSourcedAggregateRoot;
     return $eventSourcedAggregateRoot;
 }
 /**
  * Returns null if no stream events can be found for aggregate root otherwise the reconstituted aggregate root
  *
  * @param string $aggregateId
  * @return null|object
  */
 public function getAggregateRoot($aggregateId)
 {
     Assertion::string($aggregateId, 'AggregateId needs to be string');
     if (isset($this->identityMap[$aggregateId])) {
         return $this->identityMap[$aggregateId];
     }
     $streamEvents = $this->streamStrategy->read($this->aggregateType, $aggregateId);
     if (count($streamEvents) === 0) {
         return;
     }
     $aggregateType = $this->streamStrategy->getAggregateRootType($this->aggregateType, $streamEvents);
     $eventSourcedAggregateRoot = $this->aggregateTranslator->reconstituteAggregateFromHistory($aggregateType, $streamEvents);
     $this->identityMap[$aggregateId] = $eventSourcedAggregateRoot;
     return $eventSourcedAggregateRoot;
 }