public function DefaultSmsProvider::send in SMS Framework 8
Same name and namespace in other branches
- 2.x src/Provider/DefaultSmsProvider.php \Drupal\sms\Provider\DefaultSmsProvider::send()
- 2.1.x src/Provider/DefaultSmsProvider.php \Drupal\sms\Provider\DefaultSmsProvider::send()
Sends an SMS using the active gateway.
It is preferred to use queue method over directly invoking send().
Parameters
\Drupal\sms\Message\SmsMessageInterface $sms: The message to be sent.
Return value
\Drupal\sms\Message\SmsMessageInterface[] The messages sent in this sending operation. The message sent can be transformed into multiple messages depending on gateway and event subscribers. Therefore this function can return multiple messages.
Throws
\Drupal\sms\Exception\RecipientRouteException Thrown if no gateway could be determined for the message.
Overrides SmsProviderInterface::send
1 call to DefaultSmsProvider::send()
- DefaultSmsProvider::queue in src/
Provider/ DefaultSmsProvider.php - Queue a SMS message for sending or receiving.
File
- src/
Provider/ DefaultSmsProvider.php, line 96
Class
- DefaultSmsProvider
- The SMS provider that provides default messaging functionality.
Namespace
Drupal\sms\ProviderCode
public function send(SmsMessageInterface $sms) {
$sms
->setDirection(Direction::OUTGOING);
$dispatch = !$sms
->getOption('_skip_preprocess_event');
$sms_messages = $dispatch ? $this
->dispatchEvent(SmsEvents::MESSAGE_PRE_PROCESS, [
$sms,
])
->getMessages() : [
$sms,
];
$sms_messages = $this
->dispatchEvent(SmsEvents::MESSAGE_OUTGOING_PRE_PROCESS, $sms_messages)
->getMessages();
// Iterate over messages individually since pre-process can modify the
// gateway used.
foreach ($sms_messages as &$sms_message) {
$plugin = $sms_message
->getGateway()
->getPlugin();
$result = $plugin
->send($sms_message);
$sms_message
->setResult($result);
$this
->dispatchEvent(SmsEvents::MESSAGE_OUTGOING_POST_PROCESS, [
$sms_message,
]);
$this
->dispatchEvent(SmsEvents::MESSAGE_POST_PROCESS, [
$sms_message,
]);
}
return $sms_messages;
}