You are here

public function SpoolStorage::issueSummary in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Spool/SpoolStorage.php \Drupal\simplenews\Spool\SpoolStorage::issueSummary()
  2. 8 src/Spool/SpoolStorage.php \Drupal\simplenews\Spool\SpoolStorage::issueSummary()

Returns a summary of key newsletter issue parameters.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $issue: The newsletter issue entity.

Return value

array An array containing the following elements:

  • count: total number of emails that will be sent or have been sent.
  • sent_count: number of emails sent.
  • error_count: number of send errors.
  • description: readable description of status and email counts.

Overrides SpoolStorageInterface::issueSummary

File

src/Spool/SpoolStorage.php, line 333

Class

SpoolStorage
Default database spool storage.

Namespace

Drupal\simplenews\Spool

Code

public function issueSummary(ContentEntityInterface $issue) {
  $status = $issue->simplenews_issue->status;
  $params['@sent'] = $summary['sent_count'] = (int) $issue->simplenews_issue->sent_count;
  $params['@error'] = $summary['error_count'] = (int) $issue->simplenews_issue->error_count;
  $params['@count'] = $summary['count'] = (int) $issue->simplenews_issue->subscribers;
  if ($status == SIMPLENEWS_STATUS_SEND_READY) {
    $summary['description'] = $this
      ->t('Newsletter issue sent to @sent subscribers, @error errors.', $params);
  }
  elseif ($status == SIMPLENEWS_STATUS_SEND_PENDING) {
    $summary['description'] = $this
      ->t('Newsletter issue is pending, @sent mails sent out of @count, @error errors.', $params);
  }
  else {
    $params['@count'] = $summary['count'] = $this
      ->issueCountRecipients($issue);
    if ($status == SIMPLENEWS_STATUS_SEND_NOT) {
      $summary['description'] = $this
        ->t('Newsletter issue will be sent to @count subscribers.', $params);
    }
    else {
      $summary['description'] = $this
        ->t('Newsletter issue will be sent to @count subscribers on publish.', $params);
    }
  }
  return $summary;
}