/**
  * @param Contract $streamContract
  * @param Identifier $streamId
  * @return EventEnvelope[]
  */
 public function fetch(Contract $streamContract, Identifier $streamId)
 {
     return _\toArray(_\map($this->toEventEnvelope(), _\filter($this->belongsToStream($streamContract, $streamId), $this->records)));
 }
Пример #2
0
 /**
  * @param Contract $aggregateContract
  * @param Identifier $aggregateId
  * @return Aggregate
  */
 private function findTrackedAggregate(Contract $aggregateContract, Identifier $aggregateId)
 {
     $aggregates = _\toArray(_\filter(function (Aggregate $aggregate) use($aggregateContract, $aggregateId) {
         return $aggregate->isIdentifiedBy($aggregateContract, $aggregateId);
     }, $this->trackedAggregates));
     // ugh I'm missing all kinds of FP shizzle to make this pretty. Maybe later.
     /** @var Aggregate $aggregate */
     $aggregate = count($aggregates) ? $aggregates[0] : null;
     return $aggregate;
 }