public function RecipientHandlerSelectBase::addToSpool in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/simplenews/RecipientHandler/RecipientHandlerSelectBase.php \Drupal\simplenews\Plugin\simplenews\RecipientHandler\RecipientHandlerSelectBase::addToSpool()
Adds a newsletter issue to the mail spool.
Return value
int Number of recipients added.
Overrides RecipientHandlerInterface::addToSpool
File
- src/
Plugin/ simplenews/ RecipientHandler/ RecipientHandlerSelectBase.php, line 17
Class
- RecipientHandlerSelectBase
- Base for Recipient Handlers that access the database directly using Select.
Namespace
Drupal\simplenews\Plugin\simplenews\RecipientHandlerCode
public function addToSpool() {
$entity_type = $this->issue
->getEntityTypeId();
$query = $this
->buildRecipientQuery();
$query
->addExpression("'{$entity_type}'", 'entity_type');
$query
->addExpression($this->issue
->id(), 'entity_id');
$query
->addExpression(SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED, 'status');
$query
->addExpression(REQUEST_TIME, 'timestamp');
$this->connection
->insert('simplenews_mail_spool')
->from($query)
->execute();
return $query
->countQuery()
->execute()
->fetchField();
}