Which is the best entrance for a prizing discourse? When reply to a topic, will win a prize by chance, to attract more people to take part in

Hi, long time no see!

I learned the link you pasted above. And learned that event may be the best way to approach the goal.

And also I have read Using the EventManager - tutorials - Laminas Docs several times.

Still I have problems to practise in my project.

  1. I don’t know where to place the following code, in the Module.php?(I only found attach method in the onBootstrap() of Module.php file)
$events->attach('do', function ($e) {});
  1. the PM said that, we may hold different activities(promotions) onside a topic. I am planning to write different classes for different promotion logics. each class encapsulate a concrete promotion logic. this way will provide flexibility to me. I can write anything inside the class.
    My question is that how to involve the promotion class(as well as promotion class instance) in/with the event stuff?

  2. how to trigger the event after comment done. in another saying, where to place the trigger related code

$events->trigger('do', null, $params);

should I put it inside the CommentTable’s save() method?

You said it should decoupled with controller and action. inside the comment model you suggested. But I don’t know how. I am still looking forward to your example.