You are here

public static function PrepareUninstallForm::deleteSubscribers in Simplenews 8.2

Same name and namespace in other branches
  1. 8 src/Form/PrepareUninstallForm.php \Drupal\simplenews\Form\PrepareUninstallForm::deleteSubscribers()
  2. 3.x src/Form/PrepareUninstallForm.php \Drupal\simplenews\Form\PrepareUninstallForm::deleteSubscribers()

Deletes Simplenews subscribers.

File

src/Form/PrepareUninstallForm.php, line 65

Class

PrepareUninstallForm
Removes fields and data used by Simplenews.

Namespace

Drupal\simplenews\Form

Code

public static function deleteSubscribers(&$context) {
  $storage = \Drupal::entityTypeManager()
    ->getStorage('simplenews_subscriber');
  $subscriber_ids = $storage
    ->getQuery()
    ->range(0, 100)
    ->execute();
  if ($subscribers = $storage
    ->loadMultiple($subscriber_ids)) {
    $storage
      ->delete($subscribers);
  }
  $context['finished'] = (int) count($subscriber_ids) < 100;
}