public function SmsQueueProcessor::processUnqueued in SMS Framework 2.x
Same name and namespace in other branches
- 8 src/Provider/SmsQueueProcessor.php \Drupal\sms\Provider\SmsQueueProcessor::processUnqueued()
- 2.1.x src/Provider/SmsQueueProcessor.php \Drupal\sms\Provider\SmsQueueProcessor::processUnqueued()
Check for messages not in the Drupal queue and add them.
@todo rename?
Overrides SmsQueueProcessorInterface::processUnqueued
File
- src/
Provider/ SmsQueueProcessor.php, line 75
Class
- SmsQueueProcessor
- The SMS Queue Processor.
Namespace
Drupal\sms\ProviderCode
public function processUnqueued() {
/** @var \Drupal\sms\Entity\SmsGatewayInterface $sms_gateway */
$ids = [];
foreach ($this->smsGatewayStorage
->loadMultiple() as $sms_gateway) {
$query = $this->smsMessageStorage
->getQuery()
->condition('gateway', $sms_gateway
->id(), '=')
->condition('queued', 0, '=')
->condition('processed', NULL, 'IS NULL');
if (!$sms_gateway
->isScheduleAware()) {
$query
->condition('send_on', $this->time
->getRequestTime(), '<=');
}
$ids += $query
->execute();
}
/** @var \Drupal\sms\Entity\SmsMessageInterface $sms_message */
foreach ($this->smsMessageStorage
->loadMultiple($ids) as $sms_message) {
$data = [
'id' => $sms_message
->id(),
];
if ($this->queue
->createItem($data)) {
$sms_message
->setQueued(TRUE)
->save();
}
}
}