load() public method

public load ( StreamName $streamName, null | integer $minVersion = null ) : Stream | null
$streamName Prooph\EventStore\Stream\StreamName
$minVersion null | integer Minimum version an event should have
return Prooph\EventStore\Stream\Stream | null
コード例 #1
0
ファイル: EventStore.php プロジェクト: ad3n/event-store
 /**
  * @param StreamName $streamName
  * @param null|int $minVersion
  * @throws Exception\StreamNotFoundException
  * @return Stream
  */
 public function load(StreamName $streamName, $minVersion = null)
 {
     $argv = ['streamName' => $streamName, 'minVersion' => $minVersion];
     $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv);
     $this->getActionEventEmitter()->dispatch($event);
     if ($event->propagationIsStopped()) {
         $stream = $event->getParam('stream', false);
         if ($stream instanceof Stream && $stream->streamName()->toString() == $streamName->toString()) {
             return $stream;
         }
         throw new StreamNotFoundException(sprintf('A stream with name %s could not be found', $streamName->toString()));
     }
     $streamName = $event->getParam('streamName');
     $minVersion = $event->getParam('minVersion');
     $stream = $this->adapter->load($streamName, $minVersion);
     if (!$stream) {
         throw new StreamNotFoundException(sprintf('A stream with name %s could not be found', $streamName->toString()));
     }
     $event->setName(__FUNCTION__ . '.post');
     $event->setParam('stream', $stream);
     $this->getActionEventEmitter()->dispatch($event);
     if ($event->propagationIsStopped()) {
         throw new StreamNotFoundException(sprintf('A stream with name %s could not be found', $streamName->toString()));
     }
     return $event->getParam('stream');
 }