Problem/Motivation
After using the email interface for a while, I have discovered various limitations that need to be improved. This would be non-back-compatible for any custom EmailProcessorInterface implementations and there's no way to avoid that sorry, so let's get it fixed whilst the number of sites using this module is low.
Proposed resolution
1. Add an extra function EmailProcessorInterface::preBuild(), matching hook_mailer_pre_build(). Rename hook_mailer_pre_send() to be hook_mailer_post_render() matching EmailProcessorInterface::postRender().
2. Create a combined EmailInterface, removing the separate RenderedEmailInterface, UnrenderedEmailInterface and BaseEmailInterface. The split was confusing, and the original aim of constraining which functions can be called at what stage doesn't even work especially now we have a third preBuild phase. Instead we should put clear comments explaining when the functions can be called and validate this with exceptions.
3. Create direct access functions corresponding to all functions of the underlying Symfony Email instead of having to call getInner() (which has been removed). Allow most of these functions to be called before rendering which avoids forcing classes like CommerceEmailBuilder and SimplenewsNewsletterEmailBuilder to implement postRender(). For consistency with Drupal and the rest of this module we prefix the set accessors with "set". The file BaseEmailInterface contains the interface for all wrappers, which keeps EmailInterface shorter and more readable.
Remaining tasks
API changes
As above.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | symfony-mailer.email-interface.3253847-3.patch | 65.07 KB | adamps |
| #2 | symfony-mailer.email-interface.3253847-2.patch | 63.49 KB | adamps |
Comments
Comment #2
adamps commentedI feel we should do this ASAP before many people have written code that would need changing.
Comment #3
adamps commentedComment #4
adamps commentedComment #6
adamps commented