Exemple #1
0
 private function evaluateConditions(callable $conditions)
 {
     $evaluatedConditions = [];
     foreach ($this->store->allEvents() as $event) {
         $evaluatedConditions[] = $this->evaluateConditionsFor($conditions, $event);
     }
     return $evaluatedConditions;
 }
Exemple #2
0
 public function that($event, $aggregateIdentifier)
 {
     foreach ($this->listeners as $listener) {
         if ($listener->listensTo($event)) {
             $listener->on($event);
         }
     }
     $this->store->append($event, $aggregateIdentifier);
 }
Exemple #3
0
 /**
  * @param mixed|null $query
  * @return object
  * @throws \Exception
  */
 public function project($query = null)
 {
     $projection = $this->projections->buildProjection($query);
     if (!is_object($projection)) {
         throw new \Exception('Projection must be an object.');
     }
     $this->applyEvents($projection, $this->store->allEvents());
     return $projection;
 }
Exemple #4
0
 private function appendEvents($events, $identifier)
 {
     foreach ($events as $event) {
         $this->store->append($event, $identifier);
     }
 }
Exemple #5
0
 public function appendedEvents()
 {
     return $this->store->allEvents();
 }