# Token Aliases
This modules allows it to use Token replacements, were the data is provided via $data argument, with aliases.
Motivation:
https://www.drupal.org/project/drupal/issues/1920688#comment-15137142
$token_service = \Drupal::service('token_aliases');
$string = 'Hello [user1:username], we have news from [user2:username] see [node:title] and [my_node:title] for more info.';
// Fully loaded Drupal entities which are keys with the aliases used in the string.
$data = [
'user1' => $user1,
'user2' => $user2,
'node' => $node,
'my_node' => $my_node,
];
$result = $token_service->plainReplace($string, $data);
Note: It uses a multi-pass approach to achieve that. Which means, it utilizes the original Token doReplace() method as much as possible, by converting aliases back to the original entity types almost one by one.
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the Token ecosystem
Most installed first