From 862b82f6585bfa274269e6fcfd0335d58384081c Mon Sep 17 00:00:00 2001 From: Amitai Burstein Date: Wed, 29 Apr 2020 19:20:20 +0300 Subject: [PATCH] Add Message notifier interface --- src/MessageNotifier.php | 19 ++----------------- src/MessageNotifierInterface.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 src/MessageNotifierInterface.php diff --git a/src/MessageNotifier.php b/src/MessageNotifier.php index f1e62d8..abb42ae 100644 --- a/src/MessageNotifier.php +++ b/src/MessageNotifier.php @@ -9,7 +9,7 @@ /** * Prepare and send notifications. */ -class MessageNotifier { +class MessageNotifier implements MessageNotifierInterface { /** * The notifier plugin manager. @@ -29,21 +29,7 @@ public function __construct(Manager $notifier_manager) { } /** - * Process and send a message. - * - * @param \Drupal\message\MessageInterface $message - * The message entity being used for the notification. - * @param array $options - * Array of options to override the plugin's default ones. - * @param string $notifier_name - * Optional; The name of the notifier to use. Defaults to "email" - * sending method. - * - * @return bool - * Boolean value denoting success or failure of the notification. - * - * @throws \Drupal\message_notify\Exception\MessageNotifyException - * If no matching notifier plugin exists. + * {@inheritdoc} */ public function send(MessageInterface $message, array $options = [], $notifier_name = 'email') { if (!$this->notifierManager->hasDefinition($notifier_name, FALSE)) { @@ -56,7 +42,6 @@ public function send(MessageInterface $message, array $options = [], $notifier_n if ($notifier->access()) { return $notifier->send(); } - // @todo Throw exception instead? return FALSE; } diff --git a/src/MessageNotifierInterface.php b/src/MessageNotifierInterface.php new file mode 100644 index 0000000..38d3197 --- /dev/null +++ b/src/MessageNotifierInterface.php @@ -0,0 +1,31 @@ +