You are here

public function RecipientHandlerEntityBase::addToSpool in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/simplenews/RecipientHandler/RecipientHandlerEntityBase.php \Drupal\simplenews\Plugin\simplenews\RecipientHandler\RecipientHandlerEntityBase::addToSpool()

Adds a newsletter issue to the mail spool.

Return value

int Number of recipients added.

Overrides RecipientHandlerInterface::addToSpool

File

src/Plugin/simplenews/RecipientHandler/RecipientHandlerEntityBase.php, line 13

Class

RecipientHandlerEntityBase
Base for Recipient Handler classes based on EntityQuery.

Namespace

Drupal\simplenews\Plugin\simplenews\RecipientHandler

Code

public function addToSpool() {
  $query = $this
    ->buildEntityQuery();
  $ids = $query
    ->execute();
  $field = $query
    ->getEntityTypeId() == 'user' ? 'uid' : 'snid';
  $this
    ->addArrayToSpool($field, $ids);
  return count($ids);
}