Skip to content

Instantly share code, notes, and snippets.

@chriscalip
Created August 15, 2017 17:59
Show Gist options
  • Save chriscalip/58afae770105559e0f01cb6d8afc3972 to your computer and use it in GitHub Desktop.
Save chriscalip/58afae770105559e0f01cb6d8afc3972 to your computer and use it in GitHub Desktop.
Drupal 8, Is it possible to override current-user for token replace purposes?
$token = Drupal::token();
$text = 'New [node:content-type] created: [node:title] [current-user:display-name]';
$node = node_load(80044);
$user = user_load(2);
$token->replace($text, ['node' => $node, 'current-user' => $user]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment