You are here

public function PrivateMessageThread::addMessage in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Entity/PrivateMessageThread.php \Drupal\private_message\Entity\PrivateMessageThread::addMessage()

Add a private message to the list of messages in this thread.

Parameters

Drupal\private_message\Entity\PrivateMessageInterface $privateMessage: The private message to be added to the thread.

Return value

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

Overrides PrivateMessageThreadInterface::addMessage

File

src/Entity/PrivateMessageThread.php, line 86

Class

PrivateMessageThread
Defines the Private Message Thread entity.

Namespace

Drupal\private_message\Entity

Code

public function addMessage(PrivateMessageInterface $privateMessage) {
  $this
    ->get('private_messages')
    ->appendItem($privateMessage
    ->id());
  return $this;
}