You are here

public function DigestManager::processDigests in Message Digest 8

Processes digests waiting to be aggregated.

These are queued for processing and sending individually.

Overrides DigestManagerInterface::processDigests

File

src/DigestManager.php, line 153

Class

DigestManager
Digest manager service.

Namespace

Drupal\message_digest

Code

public function processDigests() {
  foreach ($this
    ->getNotifiers() as $notifier) {
    if ($notifier
      ->processDigest()) {

      // Gather up all the messages into neat little digests and send 'em out.
      // It is up to each digest plugin to manage last sent time, etc.
      // @see \Drupal\message_digest\Plugin\Notifier\DigestBase
      $recipients = $notifier
        ->getRecipients();
      $end_time = $notifier
        ->getEndTime();
      foreach ($recipients as $uid) {

        // Queue each recipient digest for processing and sending.
        $data = [
          'uid' => $uid,
          'notifier_id' => $notifier
            ->getPluginId(),
          'end_time' => $end_time,
        ];
        $this->queue
          ->createItem($data);
      }
      $notifier
        ->setLastSent();
    }
  }
}