You are here

public function MessageNotifierBase::send in Message Notify 8

Entry point to send and process a message.

Return value

bool TRUE or FALSE based on delivery status.

Overrides MessageNotifierInterface::send

File

src/Plugin/Notifier/MessageNotifierBase.php, line 98

Class

MessageNotifierBase
An abstract implementation of MessageNotifierInterface.

Namespace

Drupal\message_notify\Plugin\Notifier

Code

public function send() {
  $has_message = isset($this->message);
  assert($has_message, 'No message is set for this notifier.');
  $output = [];
  $view_builder = $this->entityTypeManager
    ->getViewBuilder('message');
  foreach ($this->pluginDefinition['viewModes'] as $view_mode) {
    $build = $view_builder
      ->view($this->message, $view_mode);
    $output[$view_mode] = $this->renderer
      ->renderPlain($build);
  }
  $result = $this
    ->deliver($output);
  $this
    ->postSend($result, $output);
  return $result;
}