This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Use $this->trigger() instead of Event::trigger() to make it possible to listen to events in Behaviors #730
Labels
You can continue the conversation there. Go to discussion →
Description
I make extensive use of Feed Me events, and decided to move them to a behavior, as is also suggested in the Yii 2.0 documentation.
The problem is that some events are not picked up, and I've narrowed it down to events that are triggered in this way:
(from /services/DataTypes.php)
If the event is triggered from the object itself (like other Feed Me events are), then the Behavior will pick it up, for instance like this:
I'm guessing the issue here is that since the Behavior is attached dynamically, it's not registered when the class is added statically (btw,
self::class
gives the same result).Unless there's any specific reason to trigger events with
Event::trigger()
instead of$this->trigger()
, I would suggest to change them everywhere, so that events can be handled in behaviors consistently.The text was updated successfully, but these errors were encountered: