You are here

public function SmsMessageProcessor::deliveryReportUrl in SMS Framework 2.x

Same name and namespace in other branches
  1. 8 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 251

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) {
      }
    }
  }
}