Individual email builder class for every subtype

Created on 21 May 2022, about 3 years ago
Updated 28 May 2025, about 2 months ago

Problem/Motivation

In Allow EmailBuilder plugin not linked to module name or config entity Fixed it was stated, that EmailFactory supports having different mail builder classes for every in a given module. Specifically:

Did you try to create an EmailBuilder for a sub-type? If you look at EmailFactory::initEmail() then there is some code in this direction: it searches for a plug-in name based on the "suggestions" - which means first TYPE_SUBTYPE then TYPE. Probably this code has never been tested. I would welcome patches that fix it.

Steps to reproduce

In a custom module (e.g., custom_lesson) add multiple email builders with the following ids:

  • custom_lesson.application
  • custom_lesson.approval

This roughly implements the use case given in the other issue. I.e.:

The module provides a simple form where a (anonymous) visitor enters their email address, to be added to the waiting list for a lesson (= product variation entity). They get a confirmation message about that, and a "waiting_list_entry" content entity gets created.
So here my EmailBuilder only receives the lesson parameter.

Afterwards an admin user can send an email message to a waiting list entry entity (like "Hey, a new spot is available").
This EmailBuilder needs to receive the waiting_list_entry entity parameter.

Regrettably a module set up like this will not show up in the policy drop-down. I guess this is because EmailBuilderManager::processDefinition populates the sub_type field instead of the sub_types field of a definition.

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇭Switzerland znerol

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.71.5 2024