protected function unsubscribeDifference($listId, array $subscribers)
    {
        $mailchimpEmails = $this->listRepository->getSubscriberEmails($listId);
        $internalEmails = array_map(function (Subscriber $subscriber) {
            return $subscriber->getEmail();
        }, $subscribers);

        // emails that are present in mailchimp but not internally should be unsubscribed
        $diffenceEmails = array_diff($mailchimpEmails, $internalEmails);
        if (sizeof($diffenceEmails) == 0) {
            return;
        }

        $this->listRepository->batchUnsubscribe($listId, $diffenceEmails);
    }
protected function unsubscribeDifference($listId, array $subscribers)
    {
        $mailchimpEmails = $this->listRepository->getSubscriberEmails($listId);
        $internalEmails = array_map(function (Subscriber $subscriber) {
            return $subscriber->getEmail();
        }, $subscribers);

        // emails that are present in mailchimp but not internally should be unsubscribed
        $diffenceEmails = array_diff($mailchimpEmails, $internalEmails);
        if (sizeof($diffenceEmails) == 0) {
            return;
        }

        $this->listRepository->batchUnsubscribe($listId, $diffenceEmails);
    }
protected function unsubscribeDifference ( $ listId , array $ subscribers ) { $ mailchimpEmails = $ this -> listRepository -> getSubscriberEmails ( $ listId ) ; $ internalEmails = array_map ( function ( Subscriber $ subscriber ) { return $ subscriber -> getEmail ( ) ; } , $ subscribers ) ; // emails that are present in mailchimp but not internally should be unsubscribed $ diffenceEmails = array_diff ( $ mailchimpEmails , $ internalEmails ) ; if ( sizeof ( $ diffenceEmails ) == 0 ) { return ; } $ this -> listRepository -> batchUnsubscribe ( $ listId , $ diffenceEmails ) ; }
Unsubscribe the difference between the array subscriber an user
@param string $listId
@param array $subscribers
@return void
Unsubscribe the difference between the array subscriber an user