コード例 #1
0
 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));
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public function setUp()
 {
     parent::setUp();
     $this->event = DomainEvent::wrap('Cat', 'Tiger', new ModelEvent());
 }
コード例 #4
0
 public function __invoke(DomainEvent $event)
 {
     return $event->withModelId($this->modelId);
 }
コード例 #5
0
 /**
  * @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);
 }