You are here

public function PrivateMessageThreadManager::saveThread in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Service/PrivateMessageThreadManager.php \Drupal\private_message\Service\PrivateMessageThreadManager::saveThread()

Saves a private message thread.

A new thread will be created if one does not already exist.

Parameters

\Drupal\private_message\Entity\PrivateMessageInterface $message: The new message object.

array $recipients: (optional) An array of message recipients. Defaults to an empty array.

array $excludeFromMail: (optional) An array of members to exclude from notification emails. Defaults to an empty array.

\Drupal\private_message\Entity\PrivateMessageThreadInterface|null $thread: (optional) The private message thread. If NULL, one will be loaded using the recipients array.

Overrides PrivateMessageThreadManagerInterface::saveThread

File

src/Service/PrivateMessageThreadManager.php, line 77

Class

PrivateMessageThreadManager
The Private Message generator class.

Namespace

Drupal\private_message\Service

Code

public function saveThread(PrivateMessageInterface $message, array $recipients = [], array $excludeFromMail = [], PrivateMessageThreadInterface $thread = NULL) {
  $this->message = $message;
  $this->thread = $thread;
  $this->recipients = $recipients;
  $this->excludeFromMail = $excludeFromMail;
  $this
    ->getThread()
    ->addMessage()
    ->sendMail();
}