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

public replay ( StreamName $streamName, DateTimeInterfac\DateTimeInterface $since = null, array $metadata = [] ) : Iterato\Iterator
$streamName Prooph\EventStore\Stream\StreamName
$since DateTimeInterfac\DateTimeInterface
$metadata array
Результат Iterato\Iterator
Пример #1
0
 /**
  * @param StreamName[] $streamNames
  * @param DateTimeInterface|null $since
  * @param null|array $metadatas One metadata array per stream name, same index order is required
  * @return CompositeIterator
  * @throws Exception\InvalidArgumentException
  */
 public function replay(array $streamNames, DateTimeInterface $since = null, array $metadatas = null)
 {
     if (empty($streamNames)) {
         throw new Exception\InvalidArgumentException('No stream names given');
     }
     if (null === $metadatas) {
         $metadatas = [];
         foreach ($streamNames as $streamName) {
             $metadatas[] = [];
         }
     }
     if (count($streamNames) !== count($metadatas)) {
         throw new Exception\InvalidArgumentException(sprintf('One metadata per stream name needed, given %s stream names but %s metadatas', count($streamNames), count($metadatas)));
     }
     $iterators = [];
     foreach ($streamNames as $key => $streamName) {
         $iterators[] = $this->adapter->replay($streamName, $since, $metadatas[$key]);
     }
     return new CompositeIterator($iterators, function (Message $message1 = null, Message $message2) {
         if (null === $message1) {
             return true;
         }
         return $message1->createdAt()->format('U.u') > $message2->createdAt()->format('U.u');
     });
 }