You are here

public function LogGateway::send in SMS Framework 8

Sends an SMS.

Parameters

\Drupal\sms\Message\SmsMessageInterface $sms: The sms to be sent.

Return value

\Drupal\sms\Message\SmsMessageResultInterface The result of the sms messaging operation.

Overrides SmsGatewayPluginInterface::send

File

src/Plugin/SmsGateway/LogGateway.php, line 65

Class

LogGateway
Defines a logger gateway for testing and debugging.

Namespace

Drupal\sms\Plugin\SmsGateway

Code

public function send(SmsMessageInterface $sms) {
  $this->logger
    ->notice('SMS message sent to %number with the text: @message', [
    '%number' => implode(', ', $sms
      ->getRecipients()),
    '@message' => $sms
      ->getMessage(),
  ]);
  $result = new SmsMessageResult();
  foreach ($sms
    ->getRecipients() as $number) {
    $report = (new SmsDeliveryReport())
      ->setRecipient($number)
      ->setStatus(SmsMessageReportStatus::DELIVERED)
      ->setStatusMessage('DELIVERED')
      ->setTimeDelivered(REQUEST_TIME);
    $result
      ->addReport($report);
  }
  return $result;
}