public function Subscriber::getSubscription in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getSubscription()
- 3.x src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::getSubscription()
Check if the subscriber has a subscription to a certain newsletter and return it.
Parameters
string $newsletter_id: The ID of a newsletter.
Return value
\Drupal\simplenews\Plugin\Field\FieldType\SubscriptionItem Returns the subscription item if the subscriber has the subscription, otherwise FALSE.
Overrides SubscriberInterface::getSubscription
2 calls to Subscriber::getSubscription()
- Subscriber::subscribe in src/
Entity/ Subscriber.php - Add a subscription to a certain newsletter to the subscriber.
- Subscriber::unsubscribe in src/
Entity/ Subscriber.php - Delete a subscription to a certain newsletter of the subscriber.
File
- src/
Entity/ Subscriber.php, line 213
Class
- Subscriber
- Defines the simplenews subscriber entity.
Namespace
Drupal\simplenews\EntityCode
public function getSubscription($newsletter_id) {
foreach ($this->subscriptions as $item) {
if ($item->target_id == $newsletter_id) {
return $item;
}
}
return FALSE;
}