flarum / issue-archive

0 stars 0 forks source link

Event extender `listenBefore` method. #108

Open askvortsov1 opened 3 years ago

askvortsov1 commented 3 years ago

Feature Request

Is your feature request related to a problem? Please describe. This is prompted by https://github.com/FriendsOfFlarum/byobu/issues/141#issuecomment-804299827. Essentially:

As I pointed out in the GH issue, Laravel used to support ordered listeners but dropped them as that encouraged anti-patterns. However, in this particular case, I don't think there's a reasonable alternative (a middleware wouldn't work, as the policy doesn't get the request object, and the discussion object isn't created when the middleware runs).

As a result, I propose a listenBefore method on the Event extender. We should strongly discourage using this unless absolutely necessary, but since we use events to extend API controllers, I think this might be a necessary evil.