Email body policy form should show available token browser

Created on 28 November 2023, almost 2 years ago

Problem/Motivation

The description for BodyAdjuster form says:

This field may support tokens or Twig template syntax – please check the supplied default policy for possible values.

We should instead help people out. This issue covers the tokens - see ✨ Email body policy form should show available TWIG variables Needs work for the variables.

Steps to reproduce

Edit a policy and add a body element

Workaround

  1. Look at the default installed policy - this will often use most of the available tokens
  2. Look at the code in the EmailBuilder. The tokens are normally set with setParam() or this can be overridden with tokenData().

Proposed resolution

1) Add new parameter to the @EmailBuilder annotation: token_types = array of types to show in token browser.
2) Make the EmailBuilder definition available in the form

  • Add MailerPolicy::getBuilderDefinition()
  • Deprecate MailerPolicy::getCommonAdjusters(), as it's easy to get from the above
  • In PolicyEditForm::form(), call $this->entity->getBuilderDefinition() and store the result in the form.

3) Use these annotations in BodyEmailAdjuster::settingsForm(). Create a token browser with '#theme' => 'token_tree_link', and set #token_types based on the token_types annotation.

Example

UserEmailBuilder:

token_types = {"user"}

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024