function message_digest_mail in Message Digest 8
Same name and namespace in other branches
- 7 message_digest.module \message_digest_mail()
Implements hook_mail().
File
- ./
message_digest.module, line 31 - Hook implementations for the Message Digest module.
Code
function message_digest_mail($key, &$message, $params) {
if ($key === 'digest') {
$title = \Drupal::config('system.site')
->get('name');
if (!empty($params['entity_type']) && !empty($params['entity_id'])) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = \Drupal::entityTypeManager()
->getStorage($params['entity_type'])
->load($params['entity_id']);
if (!empty($entity)) {
$title = $entity
->label();
}
else {
$message['send'] = FALSE;
}
}
$message['subject'] = t('@title message digest', [
'@title' => $title,
]);
$message['body'][] = $params['body'];
}
}