public function SubscriptionStorage::getSubscriptionsByNewsletter in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Subscription/SubscriptionStorage.php \Drupal\simplenews\Subscription\SubscriptionStorage::getSubscriptionsByNewsletter()
- 3.x src/Subscription/SubscriptionStorage.php \Drupal\simplenews\Subscription\SubscriptionStorage::getSubscriptionsByNewsletter()
Returns a list of active subscriptions for a given newsletter.
WARNING: Use with caution - this might return a huge list.
Parameters
string $newsletter_id: The newsletter id.
Return value
array An array keyed by the mail address, containing another array with the keys mail, uid, language, snid and status.
Overrides SubscriptionStorageInterface::getSubscriptionsByNewsletter
File
- src/
Subscription/ SubscriptionStorage.php, line 35
Class
- SubscriptionStorage
- Default subscription storage.
Namespace
Drupal\simplenews\SubscriptionCode
public function getSubscriptionsByNewsletter($newsletter_id) {
$query = $this->database
->select('simplenews_subscriber', 'sn');
$query
->innerJoin('simplenews_subscriber__subscriptions', 'ss', 'ss.entity_id = sn.id');
$query
->fields('sn', array(
'mail',
'uid',
'langcode',
'id',
))
->fields('ss', array(
'subscriptions_status',
))
->condition('sn.status', SubscriberInterface::ACTIVE)
->condition('subscriptions_target_id', $newsletter_id)
->condition('ss.subscriptions_status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
return $query
->execute()
->fetchAllAssoc('mail');
}