public static function receiveMessages(int $from_user_id, int $to_user_id = USER_ID): array
    {
        // Direction A -> B
        $message_collection = new UsersMessageEntityRepository();
        $messages = $message_collection
            ->setWhereFromUserId($from_user_id)
            ->setWhereToUserId($to_user_id)
            ->getAsArrayOfObjects();

        // Direction B -> A
        $message_collection = new UsersMessageEntityRepository();
        $message_collection
            ->setWhereFromUserId($to_user_id)
            ->setWhereToUserId($from_user_id);

        // Combine messages
        $messages = array_merge($messages, $message_collection
            ->getAsArrayOfObjects());

        // Sort by time
        usort($messages, function($a, $b) {
            /** @var UsersMessageEntity $a */
            /** @var UsersMessageEntity $b */
            $a = $a->getTs();
            $b = $b->getTs();

            if ($a === $b) {
                return 0;
            }

            return ($a < $b) ? 1 : -1;
        });

        return $messages;
    }
public static function receiveMessages(int $from_user_id, int $to_user_id = USER_ID): array
    {
        // Direction A -> B
        $message_collection = new UsersMessageEntityRepository();
        $messages = $message_collection
            ->setWhereFromUserId($from_user_id)
            ->setWhereToUserId($to_user_id)
            ->getAsArrayOfObjects();

        // Direction B -> A
        $message_collection = new UsersMessageEntityRepository();
        $message_collection
            ->setWhereFromUserId($to_user_id)
            ->setWhereToUserId($from_user_id);

        // Combine messages
        $messages = array_merge($messages, $message_collection
            ->getAsArrayOfObjects());

        // Sort by time
        usort($messages, function($a, $b) {
            /** @var UsersMessageEntity $a */
            /** @var UsersMessageEntity $b */
            $a = $a->getTs();
            $b = $b->getTs();

            if ($a === $b) {
                return 0;
            }

            return ($a < $b) ? 1 : -1;
        });

        return $messages;
    }
public static function receiveMessages ( int $ from_user_id , int $ to_user_id = USER_ID ) : array { // Direction A -> B $ message_collection = new UsersMessageEntityRepository ( ) ; $ messages = $ message_collection -> setWhereFromUserId ( $ from_user_id ) -> setWhereToUserId ( $ to_user_id ) -> getAsArrayOfObjects ( ) ; // Direction B -> A $ message_collection = new UsersMessageEntityRepository ( ) ; $ message_collection -> setWhereFromUserId ( $ to_user_id ) -> setWhereToUserId ( $ from_user_id ) ; // Combine messages $ messages = array_merge ( $ messages , $ message_collection -> getAsArrayOfObjects ( ) ) ; // Sort by time usort ( $ messages , function ( $ a , $ b ) { /** @var UsersMessageEntity $a */ /** @var UsersMessageEntity $b */ $ a = $ a -> getTs ( ) ; $ b = $ b -> getTs ( ) ; if ( $ a === $ b ) { return 0 ; } return ( $ a < $ b ) ? 1 : - 1 ; } ) ; return $ messages ; }
Notification using browser API
Get array of UserMessage

@param int $from_user_id sender user id
@param int $to_user_id   recipient user id

@return array
Notification using browser API Get array of UserMessage