public function apply(Event $event, $callback = null) { if (!$this->inReplay) { if ($callback !== null) { $this->_callbacks[] = $callback; } $this->_eventsToPublish->enqueue(DomainEvent::wrap($this->owner->getPrimaryKey(), $this->owner->className(), $event)); } }
public function testUnwrap() { $event0 = new MockEvent(); $event0->name = 'testEvent'; $record = EventRecord::wrap(DomainEvent::wrap('ModelType', 'ModelId', $event0)); $record->save(false); $event1 = $record->unwrap()->payload; expect($event0)->equals($event1); }
public function setUp() { parent::setUp(); $this->event = DomainEvent::wrap('Cat', 'Tiger', new ModelEvent()); }
public function __invoke(DomainEvent $event) { return $event->withModelId($this->modelId); }
/** * @return DomainEvent */ public function unwrap() { $config = ArrayHelper::merge($this->payload, ['name' => $this->event_name, 'class' => $this->event_type]); $payload = Yii::createObject($config); return DomainEvent::wrap($this->model_type, $this->model_id, $payload); }