You are here

public function RecipientHandlerBase::buildRecipientQuery in Simplenews 8

Implements SimplenewsRecipientHandlerInterface::buildRecipientQuery()

Overrides RecipientHandlerInterface::buildRecipientQuery

File

src/Plugin/simplenews/RecipientHandler/RecipientHandlerBase.php, line 45

Class

RecipientHandlerBase
Base class for all Recipient Handler classes.

Namespace

Drupal\simplenews\Plugin\simplenews\RecipientHandler

Code

public 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('s', 'mail');
  $select
    ->addField('t', 'subscriptions_target_id', 'newsletter_id');
  $select
    ->condition('t.subscriptions_target_id', $this->newsletter
    ->id());
  $select
    ->condition('t.subscriptions_status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
  $select
    ->condition('s.status', SubscriberInterface::ACTIVE);
  return $select;
}