Prooph\EventStore\EventStore::appendTo PHP Метод

appendTo() публичный Метод

public appendTo ( StreamName $streamName, Iterator $streamEvents ) : void
$streamName Prooph\EventStore\Stream\StreamName
$streamEvents Iterator
Результат void
    public function appendTo(StreamName $streamName, Iterator $streamEvents)
    {
        $argv = ['streamName' => $streamName, 'streamEvents' => $streamEvents];
        $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__ . '.pre', $this, $argv);
        $this->getActionEventEmitter()->dispatch($event);
        if ($event->propagationIsStopped()) {
            return;
        }
        if (!$this->inTransaction) {
            throw new RuntimeException('Append events to stream failed. EventStore is not in an active transaction');
        }
        $streamName = $event->getParam('streamName');
        $streamEvents = $event->getParam('streamEvents');
        $this->adapter->appendTo($streamName, $streamEvents);
        $this->recordedEvents->append($streamEvents);
        $event->setName(__FUNCTION__ . '.post');
        $this->getActionEventEmitter()->dispatch($event);
    }

Usage Example

Пример #1
0
 /**
  * @param AggregateType $repositoryAggregateType
  * @param string $aggregateId
  * @param Message[] $streamEvents
  * @param object $aggregateRoot
  * @throws Exception\InvalidArgumentException
  * @return void
  */
 public function appendEvents(AggregateType $repositoryAggregateType, $aggregateId, array $streamEvents, $aggregateRoot)
 {
     $arType = AggregateType::fromAggregateRoot($aggregateRoot);
     if (!$repositoryAggregateType->equals($arType)) {
         throw new Exception\InvalidArgumentException(sprintf('aggregate root mismatch between repository type %s and object type %s', $repositoryAggregateType->toString(), $arType->toString()));
     }
     $this->eventStore->appendTo($this->buildStreamName($repositoryAggregateType, $aggregateId), $streamEvents);
 }
All Usage Examples Of Prooph\EventStore\EventStore::appendTo