public function findBatchCommentsData(array $items) { if (empty($items)) { return array(); } if (OW::getUser()->isAuthenticated()) { $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId())); } $resultArray = array('_static' => array()); $creditsParams = array(); foreach ($items as $item) { if (!isset($resultArray[$item['entityType']])) { $resultArray[$item['entityType']] = array(); } $resultArray[$item['entityType']][$item['entityId']] = array('commentsCount' => 0, 'countOnPage' => $item['countOnPage'], 'commentsList' => array()); $creditsParams[$item['pluginKey']] = array('add_comment'); } if (OW::getUser()->isAuthenticated()) { $userInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId())); } // get comments count $result = $this->commentDao->findBatchCommentsCount($items); $entitiesForList = array(); foreach ($result as $item) { $resultArray[$item['entityType']][$item['entityId']]['commentsCount'] = (int) $item['count']; $entitiesForList[] = array('entityType' => $item['entityType'], 'entityId' => $item['entityId'], 'countOnPage' => $resultArray[$item['entityType']][$item['entityId']]['countOnPage']); } // get comments list $result = $this->commentDao->findBatchCommentsList($entitiesForList); $batchUserIdList = array(); foreach ($result as $item) { $resultArray[$item->entityType][$item->entityId]['commentsList'][] = $item; $batchUserIdList[] = $item->getUserId(); } $resultArray['_static']['avatars'] = BOL_AvatarService::getInstance()->getDataForUserAvatars(array_unique($batchUserIdList)); if (OW::getUser()->isAuthenticated()) { $resultArray['_static']['currentUserInfo'] = $currentUserInfo[OW::getUser()->getId()]; } $eventParams = array('actionList' => $creditsParams); $resultArray['_static']['credits'] = OW::getEventManager()->call('usercredits.batch_check_balance_for_action_list', $eventParams); return $resultArray; }