You are here

function simplenews_test_mail_alter in Simplenews 8.2

Same name and namespace in other branches
  1. 8 tests/modules/simplenews_test/simplenews_test.module \simplenews_test_mail_alter()
  2. 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 15
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'];
    $issue = $mail
      ->getIssue();
    if (!empty($issue->body->value)) {
      if ($issue->body->value == 'Nothing interesting') {
        throw new SkipMailException('There was nothing interesting to send.');
      }
    }
  }
}