You are here

protected function MessageDigestTrait::getMessageDigestNotifierForInterval in Message Digest 8

Returns the message digest notifier for the given interval.

Parameters

string $interval_id: The ID of a message digest interval. Examples of predefined intervals are 'daily' and 'weekly'.

Return value

\Drupal\message_digest\Plugin\Notifier\DigestInterface The notifier.

Throws

\RuntimeException Thrown when the requested notifier does not exist.

3 calls to MessageDigestTrait::getMessageDigestNotifierForInterval()
MessageDigestSubContext::assertDigestContains in ./message_digest.behat.inc
Checks that the digest for a user contains a certain message.
MessageDigestSubContext::assertDigestEmpty in ./message_digest.behat.inc
Checks that the given digest for a user does not contain any messages.
MessageDigestSubContext::assertDigestNotContains in ./message_digest.behat.inc
Checks that the digest for a user does not contain a certain message.

File

src/Traits/MessageDigestTrait.php, line 170

Class

MessageDigestTrait
Methods useful for testing and integrating the Message Digest module.

Namespace

Drupal\message_digest\Traits

Code

protected function getMessageDigestNotifierForInterval($interval_id) {
  $digest_interval = $this
    ->getMessageDigestInterval($interval_id)
    ->getInterval();
  $notifiers = $this
    ->getMessageDigestManager()
    ->getNotifiers();
  foreach ($notifiers as $notifier) {
    if ($notifier
      ->getInterval() === $digest_interval) {
      return $notifier;
    }
  }
  throw new \RuntimeException("No digest notifier found for interval '{$interval_id}'.");
}