Closed shamyyl closed 8 years ago
The behavior is expected. Create your own class MailSendEvent
like so:
class EmailSendEvent extends Event
{
public $payload;
}
and then call
$this->trigger(MyClass::EVENT_SEND_EMAIL, new EmailSendEvent(['payload' => 'somedata']));
I'd suggest you to take a look at command bus pattern implementation http://tactician.thephpleague.com/ and Yii2 adapter for it: https://github.com/trntv/yii2-tactician It's a little bit more complex, but maybe you'll like it.
I triggered the
MyClass::EVENT_SEND_EMAIL
:Before that I had been attached the event handler by next code:
this code:
var_dump($event->data)
returns null. Because of that code in yii\base\Component::trigger function:But i dont want to provide data in Event when attaching handler. I want to provide this when calling the trigger.
So, is this a bug or a feature?! And how i can provide my special data for each trigger calling?