function simplenews_test_mail_alter in Simplenews 8
Same name and namespace in other branches
- 8.2 tests/modules/simplenews_test/simplenews_test.module \simplenews_test_mail_alter()
- 3.x tests/modules/simplenews_test/simplenews_test.module \simplenews_test_mail_alter()
Implements hook_mail_alter().
File
- tests/
modules/ simplenews_test/ simplenews_test.module, line 12 - Hook implementations for the Simplenews Test module.
Code
function simplenews_test_mail_alter(&$message) {
if ($message['id'] == 'simplenews_node') {
/** @var \Drupal\simplenews\Mail\MailInterface $mail */
$mail = $message['params']['simplenews_mail'];
$entity = $mail
->getEntity();
if (!empty($entity->body->value)) {
if ($entity->body->value == 'Nothing interesting') {
throw new SkipMailException('There was nothing interesting to send.');
}
}
}
}