assert() public method

public assert ( $aggregateRoot )
$aggregateRoot
 /**
  * @param object $eventSourcedAggregateRoot
  * @throws Exception\AggregateTypeException
  */
 public function addAggregateRoot($eventSourcedAggregateRoot)
 {
     $this->aggregateType->assert($eventSourcedAggregateRoot);
     $domainEvents = $this->aggregateTranslator->extractPendingStreamEvents($eventSourcedAggregateRoot);
     $aggregateId = $this->aggregateTranslator->extractAggregateId($eventSourcedAggregateRoot);
     $streamName = $this->determineStreamName($aggregateId);
     $enrichedEvents = [];
     foreach ($domainEvents as $event) {
         $enrichedEvents[] = $this->enrichEventMetadata($event, $aggregateId);
     }
     if ($this->oneStreamPerAggregate) {
         $stream = new Stream($streamName, new ArrayIterator($enrichedEvents));
         $this->eventStore->create($stream);
     } else {
         $this->eventStore->appendTo($streamName, new ArrayIterator($enrichedEvents));
     }
 }
Esempio n. 2
0
 /**
  * @param object $eventSourcedAggregateRoot
  */
 protected function assertAggregateType($eventSourcedAggregateRoot)
 {
     $this->aggregateType->assert($eventSourcedAggregateRoot);
 }