public function load(ObjectManager $manager) { $firstComment = new Comment(); $firstComment->setCommentBody('comment'); $firstComment->setParentComment(null); $firstComment->setQuestion($this->getReference('question1')); $this->addReference('comment1', $firstComment); $manager->persist($firstComment); $manager->flush(); }
public function noticePollCommented(Comment $comment) { $question = $comment->getQuestion(); if (!$question->getUser() instanceof Group) { return; } $target = ['id' => $question->getId(), 'type' => $question->getType()]; $target['label'] = $this->getLabelByPoll($question); $target['preview'] = $this->preparePreview($comment->getCommentBody()); $socialActivity1 = (new SocialActivity(SocialActivity::TYPE_FOLLOW_POLL_COMMENTED, $comment->getUser(), $comment->getQuestion()->getUser()))->setTarget($target); if ($comment->getParentComment()->getUser()) { $target['comment_id'] = $comment->getId(); } $this->em->persist($socialActivity1); $this->em->flush($socialActivity1); if ($comment->getParentComment()->getUser() && $comment->getUser() !== $comment->getParentComment()->getUser()) { $socialActivity2 = (new SocialActivity(SocialActivity::TYPE_COMMENT_REPLIED, $comment->getUser(), $comment->getQuestion()->getUser()))->setTarget($target)->setRecipient($comment->getParentComment()->getUser()); $this->em->persist($socialActivity2); $this->em->flush($socialActivity2); $this->pt->addToQueue('sendSocialActivity', [$socialActivity2->getId()]); } }
public function updateEntityRateCount(Comment $comment) { $activities = $this->entityManager->getRepository(Activity::getActivityClassByEntity($comment->getQuestion()))->findBy(['questionId' => $comment->getQuestion()->getId()]); /* @var Activity $activity */ foreach ($activities as $activity) { $activity->setRateUp($comment->getRateUp())->setRateDown($comment->getRateDown()); $this->entityManager->flush($activity); } }
public function addPollRootComment(Question $question, $message = '') { $comment = new Comment(); $comment->setQuestion($question)->setCommentBody($message); return $this->saveNewComment($comment); }
public function getRateDown() { $this->__load(); return parent::getRateDown(); }