public function SmsMessageProcessor::chunkMaxRecipients in SMS Framework 8
Same name and namespace in other branches
- 2.x src/EventSubscriber/SmsMessageProcessor.php \Drupal\sms\EventSubscriber\SmsMessageProcessor::chunkMaxRecipients()
- 2.1.x src/EventSubscriber/SmsMessageProcessor.php \Drupal\sms\EventSubscriber\SmsMessageProcessor::chunkMaxRecipients()
Split messages to overcome gateway limits.
Parameters
\Drupal\sms\Event\SmsMessageEvent $event: The SMS message preprocess event.
File
- src/
EventSubscriber/ SmsMessageProcessor.php, line 269
Class
- SmsMessageProcessor
- Handles messages before they are processed by queue(), send(), or incoming().
Namespace
Drupal\sms\EventSubscriberCode
public function chunkMaxRecipients(SmsMessageEvent $event) {
$result = [];
foreach ($event
->getMessages() as $sms_message) {
if ($sms_message
->getDirection() == Direction::OUTGOING) {
$max = $sms_message
->getGateway()
->getMaxRecipientsOutgoing();
$result = array_merge($result, $sms_message
->chunkByRecipients($max));
}
else {
$result[] = $sms_message;
}
}
$event
->setMessages($result);
}