public static function reconstitute(EventStream $events) { $user = new static($events->aggregateId()); foreach ($events as $event) { $user->apply($event); } return $user; }
public static function reconstitute(array $events) { $entity = new static(); foreach ($events as $event) { $entity->apply($event); } return $entity; }
public static function reconstructFrom(AggregateRootId $id, EventStream $eventStream) { $aggregate = new static($id); foreach ($eventStream as $event) { $aggregate->apply($event); } return $aggregate; }
/** * Recreates an instance of the Entity from a stream of events * * @param EventStream $stream * @return EventSourcedEntity */ public static function reconstitute(EventStream $stream) { $entity = new static(); foreach ($stream as $message) { $entity->apply($message->getEvent()); } $entity->initStream(true); return $entity; }
public static function reconstituteFrom(Identifier $id, DomainEvents $domainEvents, DomainEvents $pendingChanges = null) { $aggregate = new static($id); foreach ($domainEvents as $event) { $aggregate->apply($event); } if ($pendingChanges) { foreach ($pendingChanges as $changeEvent) { $aggregate->recordPendingChange($changeEvent); } } return $aggregate; }
/** * Schedule movie. * * @param MovieId $id * @param string $name * @param DateTime $schedule * @param float $price * * @return static */ public static function schedule(MovieId $id, $name, DateTime $schedule, $price) { $movie = new static(); $movie->apply(new MovieWasScheduled($id, $name, $schedule, $price)); return $movie; }
/** * Applies customization to target component and its children. * * @param ComponentInterface $component */ public static function applyTo(ComponentInterface $component) { $inst = new static(); $inst->apply($component); }