- Issue created by @donquixote
- 🇩🇪Germany donquixote
What about symfony events?
Do symfony events allow this behavior?
I am not quite sure.
The event subscribers are determined on container rebuild time, mostly based on static information (static method getSubscribedEvents()).There is a method ->addListener() which is totally dynamic, _but_ it is not really suitable for the kind of dynamic implementations we are talking about. The method has to be called again every request before the event fires, which can be impractical.
This said, I think whatever I am proposing here for hooks could also be implemented for symfony events, if we really want to.
- Status changed to Postponed: needs info
over 1 year ago 4:00am 30 November 2023 - 🇦🇺Australia dpi Perth, Australia
Does ✨ Dynamic hook ID specific attributes Active cover this? The idea is mainly the attribute can emit multiple ID's it wants to listen for. These ID's would be build on compilation, not as a runtime _listener_.
I dont think I'd want or see the value in runtime listening, or basing it on various environmental/session based conditions. At least not something a wide-capture hook, e.g hook_entity_update vs hook_entity_TYPE_update could not condition filter itself.
- 🇩🇪Germany donquixote
Hi
The idea here is about ids determined dynamically based on stuff like config values, but not based on per-request runtime info like current user etc.E.g. imagine a module like rules where each rule could implement a hook.
Tbh I have not looked at rules module in a while, but I just did and it is interesting.https://git.drupalcode.org/project/rules/-/blob/8.x-3.x/src/EventSubscri...
https://git.drupalcode.org/project/rules/-/blob/8.x-3.x/rules.module
I see static-to-dynamic dispatching from hooks to events which looks quite wasteful.