function content_moderation_notifications_mail in Content Moderation Notifications 8.2
Same name and namespace in other branches
- 8.3 content_moderation_notifications.module \content_moderation_notifications_mail()
- 8 content_moderation_notifications.module \content_moderation_notifications_mail()
Implements hook_mail().
File
- ./
content_moderation_notifications.module, line 39 - Hook implementations for the content moderation notifications module.
Code
function content_moderation_notifications_mail($key, &$message, $params) {
$options = [
'langcode' => $message['langcode'],
];
switch ($key) {
case 'content_moderation_notification':
$message['from'] = \Drupal::config('system.site')
->get('mail');
$token_service = \Drupal::token();
$context = $params['context'];
$subject = PlainTextOutput::renderFromHtml($token_service
->replace($params['subject'], $context));
$body = $token_service
->replace($params['message'], $context);
$message['subject'] = str_replace([
"\r",
"\n",
], '', $subject);
$message['body'][] = $body;
break;
}
}