function genpass_tokens in Generate Password 8
Implements hook_tokens().
File
- ./
genpass.module, line 381 - Contains genpass.module.
Code
function genpass_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$replacements = [];
foreach ($tokens as $name => $value) {
if ($name == 'password') {
if (isset($data['user']) && isset($data['user']->password)) {
$replacements['[user:password]'] = $data['user']->password;
$replacements['[account:password]'] = $data['user']->password;
}
elseif (isset($data['user']) && !isset($data['user']->password)) {
$replacements['[user:password]'] = t('Your password');
$replacements['[account:password]'] = t('Your password');
}
}
}
return $replacements;
}