From 4341d2173ba472642ea64f94e764a18d02dc35e4 Mon Sep 17 00:00:00 2001 From: Alec Pritchard Date: Thu, 8 Feb 2018 17:17:16 +0000 Subject: [PATCH] Bugfix for Model events UserEvent::EVENT_BEFORE_CONFIRMATION and UserEvent::EVENT_AFTER_CONFIRMATION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bugfix for Model events UserEvent::EVENT_BEFORE_CREATE and UserEvent:… … …:EVENT_AFTER_CREATE Feed instance of Da\User\Event\UserEvent to resolve error in event handlers: TypeError Argument 1 passed to {closure}() must be an instance of Da\User\Event\UserEvent, instance of yii\base\Event given --- src/User/Service/UserConfirmationService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/User/Service/UserConfirmationService.php b/src/User/Service/UserConfirmationService.php index f0715b8..5958080 100644 --- a/src/User/Service/UserConfirmationService.php +++ b/src/User/Service/UserConfirmationService.php @@ -26,9 +26,12 @@ class UserConfirmationService implements ServiceInterface public function run() { - $this->model->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION); + $model = $this->model; + $event = $this->make(UserEvent::class, [$model]); + + $this->model->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION, $event); if ((bool)$this->model->updateAttributes(['confirmed_at' => time()])) { - $this->model->trigger(UserEvent::EVENT_AFTER_CONFIRMATION); + $this->model->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event); return true; }