function social_auth_extra_mail in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.2 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.3 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.4 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.5 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.6 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.7 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
- 8.8 modules/custom/social_auth_extra/social_auth_extra.module \social_auth_extra_mail()
Implements hook_mail().
File
- modules/
custom/ social_auth_extra/ social_auth_extra.module, line 373 - Contains social_auth_extra.module.
Code
function social_auth_extra_mail($key, &$message, $params) {
$token_service = \Drupal::token();
$language_manager = \Drupal::languageManager();
$langcode = $message['langcode'];
$variables = [
'user' => $params['account'],
];
$language = \Drupal::languageManager()
->getLanguage($params['account']
->getPreferredLangcode());
$original_language = $language_manager
->getConfigOverrideLanguage();
$language_manager
->setConfigOverrideLanguage($language);
$mail_config = \Drupal::config('social_auth_extra.mail');
$token_options = [
'langcode' => $langcode,
'callback' => 'user_mail_tokens',
'clear' => TRUE,
];
$message['subject'] .= PlainTextOutput::renderFromHtml($token_service
->replace($mail_config
->get($key . '.subject'), $variables, $token_options));
$message['body'][] = $token_service
->replace($mail_config
->get($key . '.body'), $variables, $token_options);
$language_manager
->setConfigOverrideLanguage($original_language);
}