public function SmsDeliveryReportsProcessor::updateDeliveryReports in SMS Framework 8
Same name and namespace in other branches
- 2.x src/EventSubscriber/SmsDeliveryReportsProcessor.php \Drupal\sms\EventSubscriber\SmsDeliveryReportsProcessor::updateDeliveryReports()
- 2.1.x src/EventSubscriber/SmsDeliveryReportsProcessor.php \Drupal\sms\EventSubscriber\SmsDeliveryReportsProcessor::updateDeliveryReports()
Updates the delivery status on stored SMS delivery reports.
Parameters
\Drupal\sms\Event\SmsDeliveryReportEvent $event: The event containing updated delivery reports status.
File
- src/
EventSubscriber/ SmsDeliveryReportsProcessor.php, line 38
Class
- SmsDeliveryReportsProcessor
- Handles delivery reports as they come in and updates storage.
Namespace
Drupal\sms\EventSubscriberCode
public function updateDeliveryReports(SmsDeliveryReportEvent $event) {
foreach ($event
->getReports() as $report) {
// Only messages that have message IDs can be tracked and updated.
if ($report
->getMessageId()) {
$existing = $this->reportStorage
->loadByProperties([
'message_id' => $report
->getMessageId(),
]);
if ($existing) {
$existing = reset($existing);
$existing
->setStatus($report
->getStatus())
->setStatusMessage($report
->getStatusMessage())
->setStatusTime($report
->getStatusTime())
->save();
}
}
}
}