You are here

public function Sms::deliver in Message Notify 8

Deliver a message via the required transport method.

Parameters

array $output: Array keyed by the view mode, and the rendered entity in the specified view mode.

Return value

bool TRUE or FALSE based on delivery status.

Overrides MessageNotifierInterface::deliver

File

src/Plugin/Notifier/Sms.php, line 17

Class

Sms
SMS notifier.

Namespace

Drupal\message_notify\Plugin\Notifier

Code

public function deliver(array $output = []) {
  throw new MessageNotifyException('This functionality depends on the SMS Framework module. See: https://www.drupal.org/node/2582937');
  if (empty($this->message->smsNumber)) {

    // Try to get the SMS number from the account.
    $account = $this->message->uid->entitiy;
    if (!empty($account->sms_user['number'])) {
      $this->message->smsNumber = $account->sms_user['number'];
    }
  }
  if (empty($this->message->smsNumber)) {
    throw new MessageNotifyException('Message cannot be sent using SMS as the "smsNumber" property is missing from the Message entity or user entity.');
  }
  return sms_send($this->message->smsNumber, strip_tags($output['message_notify_sms_body']));
}