/** * {@inheritdoc} */ public function apply(DomainEventInterface $event) { if (true === $this->terminated) { throw new LogicException(sprintf('"%s" has been deleted.', get_called_class())); } $this->aggregateRoot->apply($event); }
/** * Serialize aggregate root with metadata. * * @param AggregateRootInterface $aggregate * * @return array */ private function serialize(AggregateRootInterface $aggregate) { $serialized = $aggregate->serialize(); unset($serialized['version']); return ['uuid' => (string) $aggregate->getId(), 'version' => $aggregate->getVersion(), 'created' => (new DateTime())->format('Y-m-d\\TH:i:s.uP'), 'payload' => array('class' => get_class($aggregate), 'body' => $serialized)]; }