You are here

function simplenews_newsletter_get_visible in Simplenews 8

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_newsletter_get_visible()
  2. 7.2 simplenews.module \simplenews_newsletter_get_visible()
  3. 3.x simplenews.module \simplenews_newsletter_get_visible()

Loads all visible newsletters.

Does not include newsletters with the opt-out/opt-in setting set to hidden. It is possible to apply additional conditions.

Parameters

$conditions Additional conditions.:

Return value

array Filtered newsletter entities.

Related topics

3 calls to simplenews_newsletter_get_visible()
SimplenewsSubscriptionBlock::blockForm in src/Plugin/Block/SimplenewsSubscriptionBlock.php
simplenews_user_view in ./simplenews.module
Implements hook_user_view().
SubscriptionsFormBase::getNewsletters in src/Form/SubscriptionsFormBase.php
Returns the newsletters available to select from.

File

./simplenews.module, line 770
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_newsletter_get_visible($conditions = array()) {
  $query = \Drupal::entityQuery('simplenews_newsletter');
  $query
    ->condition('opt_inout', SIMPLENEWS_OPT_INOUT_HIDDEN, '<>')
    ->sort('weight');
  foreach ($conditions as $key => $value) {
    $query
      ->condition($key, $value);
  }
  $result = $query
    ->execute();
  return !empty($result) ? simplenews_newsletter_load_multiple($result) : [];
}