You are here

public function PrivateMessageThread::getNewestMessageCreationTimestamp in Private Message 8.2

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

Get the created timestamp of the newest private message in the thread.

Return value

int The Unix timestamp of the newest message in the thread

Overrides PrivateMessageThreadInterface::getNewestMessageCreationTimestamp

1 call to PrivateMessageThread::getNewestMessageCreationTimestamp()
PrivateMessageThread::delete in src/Entity/PrivateMessageThread.php
Deletes an entity permanently.

File

src/Entity/PrivateMessageThread.php, line 134

Class

PrivateMessageThread
Defines the Private Message Thread entity.

Namespace

Drupal\private_message\Entity

Code

public function getNewestMessageCreationTimestamp() {
  $messages = $this
    ->getMessages();
  $last_timestamp = 0;
  foreach ($messages as $message) {
    $creation_date = $message
      ->get('created')->value;
    $last_timestamp = $creation_date > $last_timestamp ? $creation_date : $last_timestamp;
  }
  return $last_timestamp;
}