You are here

public function PrivateMessageService::getThreadForMembers in Private Message 8

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

Retrieves the private message thread for the given members.

If no thread exists, one will be created.

Parameters

\Drupal\user\UserInterface[] $members: An array of User objects for whom the private message thread should be retrieved.

Return value

\Drupal\private_message\Entity\PrivateMessageThread A private message thread that contains all members in the thread.

Overrides PrivateMessageServiceInterface::getThreadForMembers

File

src/Service/PrivateMessageService.php, line 116

Class

PrivateMessageService
The Private Message service for the private message module.

Namespace

Drupal\private_message\Service

Code

public function getThreadForMembers(array $members) {
  $thread_id = $this->mapper
    ->getThreadIdForMembers($members);
  if ($thread_id) {
    return $this->pmThreadManager
      ->load($thread_id);
  }
  else {
    return $this
      ->createPrivateMessageThread($members);
  }
}