Token Replacement

Last updated on
28 March 2018

Both message's body and subject allow the use of tokens.

By default, every message can use global tokens and a sender-recipient token which provides tokens for the account of the user that will receive the message. You can safely use this token to show a greeting with the user's name because each message is rendered separately for each recipient.

Custom modules may also allow more token types by providing the tokenTypes setting of the message or calling the message's \Drupal\sender\Entity\Message::setTokenTypes() method.

Tokens that need extra data (e.g. "node") require a $data parameter to be passed to the SenderInterface::send() method. For more information on this parameter, please check \Drupal\Core\Utility\Token::replace() documentation.

Help improve this page

Page status: No known problems

You can: