You are here

public function PrivateMessageMapper::getThreadIdFromMessage in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Mapper/PrivateMessageMapper.php \Drupal\private_message\Mapper\PrivateMessageMapper::getThreadIdFromMessage()

Load the thread id of the thread that a private message belongs to.

Parameters

Drupal\private_message\Entity\PrivateMessageInterface $privateMessage: The private message for which the thread ID of the thread it belongs to should be returned.

Return value

int The private message thread ID of the thread to which the private message belongs.

Overrides PrivateMessageMapperInterface::getThreadIdFromMessage

File

src/Mapper/PrivateMessageMapper.php, line 267

Class

PrivateMessageMapper
Interface for the Private Message Mapper class.

Namespace

Drupal\private_message\Mapper

Code

public function getThreadIdFromMessage(PrivateMessageInterface $privateMessage) {
  return $this->database
    ->queryRange('SELECT thread.id FROM {private_message_threads} AS thread JOIN ' . '{private_message_thread__private_messages} AS messages ' . 'ON messages.entity_id = thread.id AND messages.private_messages_target_id = :message_id', 0, 1, [
    ':message_id' => $privateMessage
      ->id(),
  ])
    ->fetchField();
}