You are here

public function Subscriber::getSubscribedNewsletterIds in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getSubscribedNewsletterIds()
  2. 3.x src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getSubscribedNewsletterIds()

Get the ids of all subscribed newsletters.

Return value

array of newsletter ids Returns the ids of all newsletters the subscriber is subscribed.

Overrides SubscriberInterface::getSubscribedNewsletterIds

File

src/Entity/Subscriber.php, line 225

Class

Subscriber
Defines the simplenews subscriber entity.

Namespace

Drupal\simplenews\Entity

Code

public function getSubscribedNewsletterIds() {
  $ids = array();
  foreach ($this->subscriptions as $item) {
    if ($item->status == SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED) {
      $ids[] = $item->target_id;
    }
  }
  return $ids;
}