1 | <?php |
||
24 | class ReadStatusManager implements ReadStatusManagerInterface |
||
25 | { |
||
26 | /** |
||
27 | * A message repository instance. |
||
28 | * |
||
29 | * @var MessageRepositoryInterface |
||
30 | */ |
||
31 | protected $messageRepository; |
||
32 | |||
33 | /** |
||
34 | * Helper to only flush once. |
||
35 | * |
||
36 | * If there are updates this becomes true so we know we need to flush. |
||
37 | * @var boolean defaults to false |
||
38 | */ |
||
39 | private $needsUpdate = false; |
||
40 | |||
41 | private $updatedMessages = []; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param MessageRepositoryInterface $messageRepository |
||
47 | */ |
||
48 | public function __construct(MessageRepositoryInterface $messageRepository) |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function updateReadStatusForMessageCollection( |
||
76 | |||
77 | /** |
||
78 | * Updates a message read status to a new read status. |
||
79 | * |
||
80 | * This function is protected because it does not persist the message. |
||
81 | * We only want to flush once so this is just a helper function for updateReadStatusForMessageCollection |
||
82 | * |
||
83 | * @param ReadStatus $newReadStatus The new read status |
||
84 | * @param ParticipantInterface $participant The participant where we check the read status for |
||
85 | * @param MessageInterface $message The message where we check the read status for |
||
86 | * |
||
87 | * @throws \InvalidArgumentException When no message meta found for given participant |
||
88 | * |
||
89 | * @return boolean true if the message has been updated, false otherwise |
||
90 | */ |
||
91 | protected function maybeMarkMessageAs( |
||
108 | |||
109 | /** |
||
110 | * Helper function to only flush once |
||
111 | */ |
||
112 | protected function maybeFlush() |
||
119 | |||
120 | |||
121 | /** |
||
122 | * Updates the thread meta unread count for the participant. |
||
123 | * |
||
124 | * @param MessageInterface $message |
||
125 | * @param ParticipantInterface $participant |
||
126 | * @param ReadStatus $newReadStatus |
||
127 | */ |
||
128 | protected function updateThreadMetaUnreadCount( |
||
155 | } |
||
156 |