3 namespace wcf\system\user\activity\event
;
5 use wcf\data\comment\Comment
;
6 use wcf\data\comment\response\CommentResponse
;
7 use wcf\data\user\activity\event\ViewableUserActivityEvent
;
8 use wcf\data\user\UserProfile
;
9 use wcf\system\cache\runtime\CommentResponseRuntimeCache
;
10 use wcf\system\cache\runtime\CommentRuntimeCache
;
11 use wcf\system\cache\runtime\UserProfileRuntimeCache
;
14 * Provides a method to read the comment response, comment, and user objects related to comment
15 * response user activity events.
17 * @author Matthias Schmidt
18 * @copyright 2001-2020 WoltLab GmbH
19 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
20 * @package WoltLabSuite\Core\System\User\Activity\Event
23 trait TCommentResponseUserActivityEvent
26 * user objects for the comment authors
29 protected $commentAuthors = [];
32 * ids of the objects the comments belongs to
35 protected $commentObjectIDs = [];
38 * comment objects the responses belongs to
41 protected $comments = [];
44 * comment response the comment response user activity events belong to
45 * @var CommentResponse[]
47 protected $responses = [];
50 * Reads the data of the comment responses the given events belong to.
52 * @param ViewableUserActivityEvent[] $events
54 protected function readResponseData(array $events)
57 foreach ($events as $event) {
58 $responseIDs[] = $event->objectID
;
61 $this->responses
= CommentResponseRuntimeCache
::getInstance()->getObjects($responseIDs);
64 foreach ($this->responses
as $response) {
65 $commentIDs[] = $response->commentID
;
68 if (!empty($commentIDs)) {
69 $this->comments
= CommentRuntimeCache
::getInstance()->getObjects($commentIDs);
73 foreach ($this->comments
as $comment) {
74 $userIDs[] = $comment->userID
;
75 $this->commentObjectIDs
[] = $comment->objectID
;
77 if (!empty($userIDs)) {
78 $this->commentAuthors
= UserProfileRuntimeCache
::getInstance()->getObjects($userIDs);