Improvement to email sending interface

Created on 14 October 2022, over 1 year ago
Updated 19 September 2023, 9 months ago

Problem/Motivation

Now I've used the interface more I'm not sure it's right.

Proposed resolution

Here are my suggestions.

  • Remove EmailFactoryInterface and add the methods to MailerInterface instead.
  • Use of ...$params is not helpful because it prevents any further parameters. We can instead have array $params.
  • Add a final parameter $send = TRUE so we can merge pairs of functions newEntityEmail() and sendEntityEmail() into entityEmail().
  • Maybe merge entityEmail() and typedEmail() into email(), and the first parameter is string|ConfigEntityInterface.
  • (Notice that the interface is now much closer to MailManagerInterface::mail().)
  • Remove the call to $email->send() from MailManagerReplacement::mail(), and instead EmailBuilderInterface::fromArray() creates the email passing $message['send'].
  • Deprecate the old interface and functions, but still keep them.

Coding details:
In EmailFactory::initEmail() remove the code "Load builders with matching ID." and put it into EmailBuilderManager::applyPolicy().
Mark both EmailBuilderManager and EmailAdjusterManager services with a new tag init_email.
Create EmailInitInterface with a single function applyPolicy()
EmailFactory::initEmail() calls applyPolicy() on all tagged services.
Maybe create a new class HooksEmailProcessor extending EmailProcessorCustomBase to contain the code "Apply hooks.".

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom AdamPS

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024