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.

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new63.49 KB

I feel we should do this ASAP before many people have written code that would need changing.

adamps’s picture

Issue summary: View changes
StatusFileSize
new65.07 KB
adamps’s picture

Title: [DISCUSSION] Improvements to Email interface » Improvements to Email interface
Status: Needs review » Fixed

  • AdamPS committed 1df8487 on 1.x
    Issue #3253847 by AdamPS: Improvements to Email interface
    
adamps’s picture

Title: [DISCUSSION] Improvements to Email interface » Improvements to Email interface
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.