protected function RecipientHandlerAll::buildRecipientQuery in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/simplenews/RecipientHandler/RecipientHandlerAll.php \Drupal\simplenews\Plugin\simplenews\RecipientHandler\RecipientHandlerAll::buildRecipientQuery()
Build the query that gets the list of recipients.
Return value
\Drupal\Core\Database\Query\SelectInterface Query with the columns 'snid' and 'newsletter_id' for each recipient.
Overrides RecipientHandlerSelectBase::buildRecipientQuery
File
- src/
Plugin/ simplenews/ RecipientHandler/ RecipientHandlerAll.php, line 23
Class
- RecipientHandlerAll
- This handler sends a newsletter issue to all its subscribers.
Namespace
Drupal\simplenews\Plugin\simplenews\RecipientHandlerCode
protected function buildRecipientQuery() {
$select = \Drupal::database()
->select('simplenews_subscriber', 's');
$select
->innerJoin('simplenews_subscriber__subscriptions', 't', 's.id = t.entity_id');
$select
->addField('s', 'id', 'snid');
$select
->addField('t', 'subscriptions_target_id', 'newsletter_id');
$select
->condition('t.subscriptions_target_id', $this
->getNewsletterId());
$select
->condition('t.subscriptions_status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
$select
->condition('s.status', SubscriberInterface::ACTIVE);
return $select;
}