public function createSnapshot(AggregateId $aggregateId) : void
    {
        if (!$this->eventSourced($aggregateId)) {
            return;
        }
        /* @var $aggregateRoot EventSourcedAggregateRoot */
        $aggregateRoot = $this->loadSnapshot($aggregateId);
        $stateHash = $aggregateRoot === null ? null : $aggregateRoot->stateHash();
        $events = $this->getEventsFor($aggregateId, $stateHash);
        if ($events->count() == 0) {
            return;
        }
        if ($aggregateRoot === null) {
            $aggregateRoot = ObjectClass::forName($aggregateId->aggregateClass())->newInstanceWithoutConstructor();
        }
        $aggregateRoot->loadFromHistory($events);
        $this->doCreateSnapshot($aggregateRoot);
    }
public function createSnapshot(AggregateId $aggregateId) : void
    {
        if (!$this->eventSourced($aggregateId)) {
            return;
        }
        /* @var $aggregateRoot EventSourcedAggregateRoot */
        $aggregateRoot = $this->loadSnapshot($aggregateId);
        $stateHash = $aggregateRoot === null ? null : $aggregateRoot->stateHash();
        $events = $this->getEventsFor($aggregateId, $stateHash);
        if ($events->count() == 0) {
            return;
        }
        if ($aggregateRoot === null) {
            $aggregateRoot = ObjectClass::forName($aggregateId->aggregateClass())->newInstanceWithoutConstructor();
        }
        $aggregateRoot->loadFromHistory($events);
        $this->doCreateSnapshot($aggregateRoot);
    }
public function createSnapshot ( AggregateId $ aggregateId ) : void { if ( ! $ this -> eventSourced ( $ aggregateId ) ) { return ; } /* @var $aggregateRoot EventSourcedAggregateRoot */ $ aggregateRoot = $ this -> loadSnapshot ( $ aggregateId ) ; $ stateHash = $ aggregateRoot === null ? null : $ aggregateRoot -> stateHash ( ) ; $ events = $ this -> getEventsFor ( $ aggregateId , $ stateHash ) ; if ( $ events -> count ( ) == 0 ) { return ; } if ( $ aggregateRoot === null ) { $ aggregateRoot = ObjectClass :: forName ( $ aggregateId -> aggregateClass ( ) ) -> newInstanceWithoutConstructor ( ) ; } $ aggregateRoot -> loadFromHistory ( $ events ) ; $ this -> doCreateSnapshot ( $ aggregateRoot ) ; }
Events raised in the current transaction are not being stored in this snapshot.
Only the already persisted events are being utilized.

@param AggregateId $aggregateId
Events raised in the current transaction are not being stored in this snapshot . Only the already persisted events are being utilized .