Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293622

Introduce theme negotiator for mail and use it in mail manager

$
0
0

Problem/Motivation

Part of #1803948: [META] Adopt the symfony mailer component but benefits the current mail system as well. Also see #2621018: Support rendering from a manually specified theme for why we need this no matter how the mail building part is going to look in the future.

Steps to reproduce

Proposed resolution

Implement a mail theme negotiation mechanism following the pattern already known from core page theme negotiation and provide a way to execute a closure inside the scope of the negotiated mail theme.

  1. Add a Drupal\Core\MailTheme\MailTemplateId value object. The mail template id unambiguously identifies the email to be sent in the current mail manager based mail system. In addition it is forward compatible with mail templates of a different kind in the upcoming mail API based on Symfony mailer.
  2. Add a Drupal\Core\MailTheme\MailThemeManager with one method: executeInMailTheme(MailTemplateId $templateId, callable $function)
  3. Add Drupal\Core\MailTheme\MailThemeNegotiator which works analogous to theme negotiation
  4. Add Drupal\Core\MailTheme\DefaultNegotiator with a low priority which falls back to the configured theme.
  5. Switch the theme before building / sending mails from within plugin.manager.mail

This is basically cherry-picking from contrib Mailsystem.

Other approaches

Some attempts were made in the past to allow specify the theme to be used for rendering (with no resolution yet):

The Drupal Symfony Mailer project implemented this functionality in a more flexible way. However, since it is reusing patterns unique to that module, the mechanism isn't easily portable to current core architecture.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293622

Trending Articles