Exemple #1
0
 /**
  * @param Event $event
  */
 protected function apply(Event $event)
 {
     $method = sprintf('apply%s', $event->name());
     if (!method_exists($this, $method)) {
         throw new BadMethodCallException(sprintf('Method %s::%s is not found.', static::className(), $method));
     }
     $this->{$method}($event);
     $this->unCommittedEvents[] = new DefaultMessage(static::className(), $this->getId(), new Metadata(), $event);
 }
Exemple #2
0
 /**
  * @param $type
  * @param Id $aggregateRootId
  * @param Metadata $metadata
  * @param Event $data
  */
 public function __construct($type, Id $aggregateRootId, Metadata $metadata, Event $data)
 {
     $this->type = $type;
     $this->name = $data->name();
     $this->aggregateRootId = $aggregateRootId;
     $this->dateTime = DateTimeOfDay::now();
     $this->metadata = $metadata;
     $this->data = $data;
 }