You are here

public function SocialPrivateMessageInboxBlock::customSort in Open Social 8

Sorts the inbox based on last updated time.

File

modules/social_features/social_private_message/src/Plugin/Block/SocialPrivateMessageInboxBlock.php, line 76

Class

SocialPrivateMessageInboxBlock
Provides a 'SocialPrivateMessageInboxBlock' block.

Namespace

Drupal\social_private_message\Plugin\Block

Code

public function customSort($pmt1, $pmt2) {

  /* @var \Drupal\private_message\Entity\PrivateMessageThread $pmt1 */

  /* @var \Drupal\private_message\Entity\PrivateMessageThread $pmt2 */
  if ($pmt1
    ->getUpdatedTime() == $pmt2
    ->getUpdatedTime()) {
    return 0;
  }
  return $pmt1
    ->getUpdatedTime() < $pmt2
    ->getUpdatedTime() ? -1 : 1;
}