Currently e-mail event sending process (internally) doesn't represent real world model, which makes it hard to improve this code with new features.
I'm proposing to:
- create kEmail class with following public methods:
- findEvent($name, $type)
- make $this->sender refer to kEmailSendingHelper class instance for easy access across all methods
- move existing code from EmailEventsEventHandler into new kEmail class
- replace OnEmailEvent event sending with new kEmail class usage
At the end interface of kApplication::EmailEventUser and kApplication::EmailEventAdmin will be almost the same (will return true/false instead of kEvent object), so no need to change code to make it working again.
Usually nobody relies on e-mail sent fact in their code anyway.