public function PrivateMessageThread::filterUserDeletedMessages in Private Message 8
Same name and namespace in other branches
- 8.2 src/Entity/PrivateMessageThread.php \Drupal\private_message\Entity\PrivateMessageThread::filterUserDeletedMessages()
Filter messages in the thread deleted by the given account.
Only messages created after the last time the user deleted the thread will be shown. If they have never deleted the thread, all messages are returned.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user for whom private messages should be returned.
Return value
Drupal\private_message\Entity\PrivateMessage[] An array of private messages
Overrides PrivateMessageThreadInterface::filterUserDeletedMessages
File
- src/
Entity/ PrivateMessageThread.php, line 308
Class
- PrivateMessageThread
- Defines the Private Message Thread entity.
Namespace
Drupal\private_message\EntityCode
public function filterUserDeletedMessages(AccountInterface $account) {
$last_delete_timestamp = $this
->getLastDeleteTimestamp($account);
$messages = $this
->getMessages();
$start_index = FALSE;
foreach ($messages as $index => $message) {
if ($message
->getCreatedTime() > $last_delete_timestamp) {
$start_index = $index;
break;
}
}
if ($start_index !== FALSE) {
return array_slice($messages, $start_index);
}
return [];
}