You are here

protected function SubscriptionsFormBase::getOnlyNewsletterId in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/SubscriptionsFormBase.php \Drupal\simplenews\Form\SubscriptionsFormBase::getOnlyNewsletterId()
  2. 8 src/Form/SubscriptionsFormBase.php \Drupal\simplenews\Form\SubscriptionsFormBase::getOnlyNewsletterId()

Convenience method for the case of only one available newsletter.

Return value

string|null If there is exactly one newsletter available in this form, this method returns its ID. Otherwise it returns NULL.

See also

::setNewsletterIds()

File

src/Form/SubscriptionsFormBase.php, line 73

Class

SubscriptionsFormBase
Entity form for Subscriber with common routines.

Namespace

Drupal\simplenews\Form

Code

protected function getOnlyNewsletterId() {
  $newsletters = $this
    ->getNewsletterIds();
  if (count($newsletters) == 1) {
    return array_shift($newsletters);
  }
  return NULL;
}