You are here

function rpt_tokens in Registration Password Token 8

Same name and namespace in other branches
  1. 7 rpt.module \rpt_tokens()

Implements hook_tokens().

File

./rpt.module, line 100
Registration Password Token module.

Code

function rpt_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];
  foreach ($tokens as $name => $value) {
    if ($name === 'password' && isset($data['user'])) {
      if (isset($data['user']->password)) {
        $replacements['[user:password]'] = $data['user']->password;
        $replacements['[account:password]'] = $data['user']->password;
      }
      else {
        $replacements['[user:password]'] = t('Your password');
        $replacements['[account:password]'] = t('Your password');
      }
    }
  }
  return $replacements;
}