Problem/Motivation

  1. Bug: missing escaping HTML before replacing variables in the subject
  2. Bug: token browser is missing for Verify emails (where the only token data is the global site)
  3. Feature: we'd like to add replacement to other fields, especially the plain text body
  4. Task: the current method is inconsistent. Token replacement happens in TokenProcessor, variable replacement of the body in BodyEmailAdjuster and variable replacement of the subject in Email.

Proposed resolution

  1. Extend TokenProcessor also to replace variables, rename it to ReplacementProcessor, and add it to all emails. Use parameters token_data and token_options to control the token replacement.
  2. The metadata from the Mailer attribute includes a value token_types so automatically use this to set the token_data parameter.
  3. Add HTML escaping before replacing variables if the value is plain text.
  4. Create ReplaceableProcessorInterface for registering token/variable replacement in an extensible way

Remaining tasks

User interface changes

API changes

Affects Mailer implementations that replace tokens.

  1. Remove all code relating to TokenTrait (1.x) or TokenProcessor (earlier version of 2.x).
  2. Use $email->setParam('token_options') if needed to set options

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

adamps created an issue. See original summary.

adamps’s picture

adamps’s picture

Issue summary: View changes

  • adamps committed fce82a5b on 2.x
    Issue #3529416 by adamps: Improvements to token/variable replacement
    
adamps’s picture

Status: Active » Fixed

adamps’s picture

Status: Fixed » Needs work

Unfortunately I only tested with site tokens - which work - but other tokens are broken.

  • adamps committed 3207b6ec on 2.x
    Issue #3529416 by adamps: Improvements to token/variable replacement
    
adamps’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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