public function noticeCommentMentioned(BaseComment $comment, $recipients) { $group = null; if ($comment instanceof MicropetitionComment) { $micropetition = $comment->getPetition(); $group = $micropetition->getGroup(); $target = ['id' => $micropetition->getId(), 'preview' => $this->preparePreview($comment->getCommentBody()), 'type' => $micropetition->getType(), 'label' => $micropetition->getType() === $micropetition::TYPE_QUORUM ? 'post' : 'petition']; } else { if ($comment instanceof Comment) { $question = $comment->getQuestion(); $target = ['id' => $question->getId(), 'type' => $question->getType()]; $target['label'] = $this->getLabelByPoll($question); $group = $question->getUser(); } } if ($comment->getParentComment()->getUser()) { $target['comment_id'] = $comment->getId(); } $user = $comment->getUser(); $target['user_id'] = $user->getId(); $target['first_name'] = $user->getFirstName(); $target['last_name'] = $user->getLastName(); foreach ($recipients as $recipient) { if ($group instanceof Group && $this->em->getRepository(UserGroup::class)->isJoinedUser($group, $recipient)) { $socialActivity = (new SocialActivity(SocialActivity::TYPE_COMMENT_MENTIONED, null, $group))->setTarget($target)->setRecipient($recipient); $this->em->persist($socialActivity); $this->em->flush($socialActivity); $this->pt->addToQueue('sendSocialActivity', [$socialActivity->getId()]); } else { if ($this->em->getRepository(UserFollow::class)->findActiveFollower($user, $recipient)) { $socialActivity = (new SocialActivity(SocialActivity::TYPE_COMMENT_MENTIONED, $user, null))->setTarget($target)->setRecipient($recipient); $this->em->persist($socialActivity); $this->em->flush($socialActivity); $this->pt->addToQueue('sendSocialActivity', [$socialActivity->getId()]); } } } }
public function getParentComment() { $this->__load(); return parent::getParentComment(); }