public static function deleteAllMembersProcessBatch(&$context) {
    if (empty($context['sandbox'])) {
      $memberIds = \Drupal::entityQuery('openy_campaign_member')->execute();
      $memberCampaignIds = \Drupal::entityQuery('openy_campaign_member_campaign')->execute();

      $context['sandbox']['progress'] = 0;

      $context['sandbox']['members'] = array_values($memberIds);
      $context['sandbox']['member_campaigns'] = array_values($memberCampaignIds);
      $context['sandbox']['max'] = count($memberCampaignIds);
    }
    // Get Member and MemberCampaign ids.
    $memberId = $context['sandbox']['members'][$context['sandbox']['progress']];
    $memberCampaignId = $context['sandbox']['member_campaigns'][$context['sandbox']['progress']];

    // Get Member entity manager.
    $memberStorage = \Drupal::entityTypeManager()
      ->getStorage('openy_campaign_member');
    // Get MemberCampaign entity manager.
    $memberCampaignStorage = \Drupal::entityTypeManager()
      ->getStorage('openy_campaign_member_campaign');

    // Delete Member entity.
    $entities = $memberStorage->loadMultiple([$memberId]);
    $memberStorage->delete($entities);
    // Delete MemberCampaign entity.
    $entities = $memberCampaignStorage->loadMultiple([$memberCampaignId]);
    $memberCampaignStorage->delete($entities);

    // Save results.
    $context['results'][] = $memberId;
    $context['sandbox']['progress']++;
    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
      $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
  }
public static function deleteAllMembersProcessBatch(&$context) {
    if (empty($context['sandbox'])) {
      $memberIds = \Drupal::entityQuery('openy_campaign_member')->execute();
      $memberCampaignIds = \Drupal::entityQuery('openy_campaign_member_campaign')->execute();

      $context['sandbox']['progress'] = 0;

      $context['sandbox']['members'] = array_values($memberIds);
      $context['sandbox']['member_campaigns'] = array_values($memberCampaignIds);
      $context['sandbox']['max'] = count($memberCampaignIds);
    }
    // Get Member and MemberCampaign ids.
    $memberId = $context['sandbox']['members'][$context['sandbox']['progress']];
    $memberCampaignId = $context['sandbox']['member_campaigns'][$context['sandbox']['progress']];

    // Get Member entity manager.
    $memberStorage = \Drupal::entityTypeManager()
      ->getStorage('openy_campaign_member');
    // Get MemberCampaign entity manager.
    $memberCampaignStorage = \Drupal::entityTypeManager()
      ->getStorage('openy_campaign_member_campaign');

    // Delete Member entity.
    $entities = $memberStorage->loadMultiple([$memberId]);
    $memberStorage->delete($entities);
    // Delete MemberCampaign entity.
    $entities = $memberCampaignStorage->loadMultiple([$memberCampaignId]);
    $memberCampaignStorage->delete($entities);

    // Save results.
    $context['results'][] = $memberId;
    $context['sandbox']['progress']++;
    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
      $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
  }
public static function deleteAllMembersProcessBatch ( & $ context ) { if ( empty ( $ context [ 'sandbox' ] ) ) { $ memberIds = \ Drupal :: entityQuery ( 'openy_campaign_member' ) -> execute ( ) ; $ memberCampaignIds = \ Drupal :: entityQuery ( 'openy_campaign_member_campaign' ) -> execute ( ) ; $ context [ 'sandbox' ] [ 'progress' ] = 0 ; $ context [ 'sandbox' ] [ 'members' ] = array_values ( $ memberIds ) ; $ context [ 'sandbox' ] [ 'member_campaigns' ] = array_values ( $ memberCampaignIds ) ; $ context [ 'sandbox' ] [ 'max' ] = count ( $ memberCampaignIds ) ; } // Get Member and MemberCampaign ids. $ memberId = $ context [ 'sandbox' ] [ 'members' ] [ $ context [ 'sandbox' ] [ 'progress' ] ] ; $ memberCampaignId = $ context [ 'sandbox' ] [ 'member_campaigns' ] [ $ context [ 'sandbox' ] [ 'progress' ] ] ; // Get Member entity manager. $ memberStorage = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'openy_campaign_member' ) ; // Get MemberCampaign entity manager. $ memberCampaignStorage = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'openy_campaign_member_campaign' ) ; // Delete Member entity. $ entities = $ memberStorage -> loadMultiple ( [ $ memberId ] ) ; $ memberStorage -> delete ( $ entities ) ; // Delete MemberCampaign entity. $ entities = $ memberCampaignStorage -> loadMultiple ( [ $ memberCampaignId ] ) ; $ memberCampaignStorage -> delete ( $ entities ) ; // Save results. $ context [ 'results' ] [ ] = $ memberId ; $ context [ 'sandbox' ] [ 'progress' ] ++ ; if ( $ context [ 'sandbox' ] [ 'progress' ] != $ context [ 'sandbox' ] [ 'max' ] ) { $ context [ 'finished' ] = $ context [ 'sandbox' ] [ 'progress' ] / $ context [ 'sandbox' ] [ 'max' ] ; } }
Processes the members deletion batch.

@param array $context
The batch context.
Processes the members deletion batch .