You are here

protected function PrivateMessageService::createPrivateMessageThread in Private Message 8

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

Create a new private message thread for the given users.

Parameters

\Drupal\user\Entity\User[] $members: An array of users who will be members of the given thread.

Return value

\Drupal\private_message\Entity\PrivateMessageThread The new private message thread.

1 call to PrivateMessageService::createPrivateMessageThread()
PrivateMessageService::getThreadForMembers in src/Service/PrivateMessageService.php
Retrieves the private message thread for the given members.

File

src/Service/PrivateMessageService.php, line 316

Class

PrivateMessageService
The Private Message service for the private message module.

Namespace

Drupal\private_message\Service

Code

protected function createPrivateMessageThread(array $members) {
  $thread = $this->pmThreadManager
    ->create();
  foreach ($members as $member) {
    $thread
      ->addMember($member);
  }
  $thread
    ->save();
  return $thread;
}