smsModel->getRepository()->getPublishedBroadcastsIterable($event->getId()); foreach ($smses as $sms) { $this->contactLimiter = new ContactLimiter($event->getBatch(), null, $event->getMinContactIdFilter(), $event->getMaxContactIdFilter(), [], $event->getThreadId(), $event->getMaxThreads(), $event->getLimit()); $this->result = new BroadcastResult(); try { $this->send($sms); } catch (\Exception) { } $event->setResults( sprintf('%s: %s', $this->translator->trans('mautic.sms.sms'), $sms->getName()), $this->result->getSentCount(), $this->result->getFailedCount() ); } } /** * @throws LimitQuotaException * @throws \Mautic\CampaignBundle\Executioner\Exception\NoContactsFoundException */ private function send(Sms $sms): void { $contacts = $this->broadcastQuery->getPendingContacts($sms, $this->contactLimiter); while (!empty($contacts)) { $reduction = 0; $leads = []; foreach ($contacts as $contact) { $contactId = $contact['id']; $results = $this->smsModel->sendSms($sms, $contactId, [ 'channel'=> [ 'sms', $sms->getId(), ], 'listId'=> $contact['listId'], ], $leads); $this->result->process($results); $reduction += count($results); } $this->contactLimiter->setBatchMinContactId($contactId + 1); if ($this->contactLimiter->hasCampaignLimit()) { $this->contactLimiter->reduceCampaignLimitRemaining($reduction); } $this->leadRepository->detachEntities($leads); // Next batch $contacts = $this->broadcastQuery->getPendingContacts($sms, $this->contactLimiter); } } }