You are here

public function SmsMessageProcessor::deliveryReportUrl in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/SmsMessageProcessor.php \Drupal\sms\EventSubscriber\SmsMessageProcessor::deliveryReportUrl()
  2. 2.1.x src/EventSubscriber/SmsMessageProcessor.php \Drupal\sms\EventSubscriber\SmsMessageProcessor::deliveryReportUrl()

Add a delivery report URL to messages.

Parameters

\Drupal\sms\Event\SmsMessageEvent $event: The SMS message preprocess event.

File

src/EventSubscriber/SmsMessageProcessor.php, line 249

Class

SmsMessageProcessor
Handles messages before they are processed by queue(), send(), or incoming().

Namespace

Drupal\sms\EventSubscriber

Code

public function deliveryReportUrl(SmsMessageEvent $event) {
  foreach ($event
    ->getMessages() as &$sms_message) {
    if (!$sms_message
      ->getOption('delivery_report_url')) {
      $url = $sms_message
        ->getGateway()
        ->getPushReportUrl();
      try {
        $url = $url
          ->setAbsolute()
          ->toString();
        $sms_message
          ->setOption('delivery_report_url', $url);
      } catch (RouteNotFoundException $e) {
      }
    }
  }
}