public function MessageNotifier::send in Message Notify 8
Process and send a message.
Parameters
\Drupal\message\MessageInterface $message: The message entity being used for the notification.
array $options: Array of options to override the plugin's default ones.
string $notifier_name: Optional; The name of the notifier to use. Defaults to "email" sending method.
Return value
bool Boolean value denoting success or failure of the notification.
Throws
\Drupal\message_notify\Exception\MessageNotifyException If no matching notifier plugin exists.
File
- src/
MessageNotifier.php, line 48
Class
- MessageNotifier
- Prepare and send notifications.
Namespace
Drupal\message_notifyCode
public function send(MessageInterface $message, array $options = [], $notifier_name = 'email') {
if (!$this->notifierManager
->hasDefinition($notifier_name, FALSE)) {
throw new MessageNotifyException('Could not send notification using the "' . $notifier_name . '" notifier.');
}
/** @var \Drupal\message_notify\Plugin\Notifier\MessageNotifierInterface $notifier */
$notifier = $this->notifierManager
->createInstance($notifier_name, $options, $message);
if ($notifier
->access()) {
return $notifier
->send();
}
// @todo Throw exception instead?
return FALSE;
}