You are here

public function Subscriber::isUnsubscribed in Simplenews 8.2

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

Check if the subscriber has an inactive subscription to a given newsletter.

Parameters

string $newsletter_id: The ID of a newsletter.

Return value

bool TRUE if the subscriber has the inactive subscription, otherwise FALSE.

Overrides SubscriberInterface::isUnsubscribed

File

src/Entity/Subscriber.php, line 207

Class

Subscriber
Defines the simplenews subscriber entity.

Namespace

Drupal\simplenews\Entity

Code

public function isUnsubscribed($newsletter_id) {
  foreach ($this->subscriptions as $item) {
    if ($item->target_id == $newsletter_id) {
      return $item->status == SIMPLENEWS_SUBSCRIPTION_STATUS_UNSUBSCRIBED;
    }
  }
  return FALSE;
}