public property MessageTemplate::$arguments in Message 8
Array with the arguments and their replacement value, or callbacks.
The argument keys will be replaced when rendering the message, and it should be prefixed by @, %, ! - similar to way it's done in Drupal core's t() function.
// Assuming out message-text is:
// %user-name created <a href="@message-url">@message-title</a>
$message_template->arguments = [
// Hard code the argument.
'%user-name' => 'foo',
// Use a callback, and provide callbacks arguments.
// The following example will call Drupal core's url() function to
// get the most up-to-date path of message ID 1.
'@message-url' => [
'callback' => 'url',
'callback arguments' => [
'message/1',
],
],
// Use callback, but instead of passing callback argument, we will
// pass the Message entity itself.
'@message-title' => [
'callback' => 'example_bar',
'pass message' => TRUE,
],
];
Arguments assigned to message-template can be overridden by the ones assigned to the message.
Type: array
File
- src/
Entity/ MessageTemplate.php, line 133
Class
- MessageTemplate
- Defines the Message template entity class.
Namespace
Drupal\message\EntityCode
public $arguments = [];