public function addMicropetitionRootComment(Micropetition $micropetition) { $comment = new MicropetitionComment(); $comment->setPetition($micropetition); $comment->setCommentBody($micropetition->getPetitionBody()); $comment->setUser($micropetition->getUser()); return $this->saveNewComment($comment); }
public function load(ObjectManager $manager) { $firstComment = new Comment(); $firstComment->setCommentBody('comment'); $firstComment->setParentComment(null); $firstComment->setPetition($this->getReference('petition1')); $this->addReference('commentPetition1', $firstComment); $manager->persist($firstComment); $manager->flush(); }
public function noticeMicropetitionCommented(Micropetitions\Comment $comment) { $micropetition = $comment->getPetition(); $target = ['id' => $micropetition->getId(), 'preview' => $this->preparePreview($comment->getCommentBody()), 'type' => $micropetition->getType(), 'label' => $micropetition->getType() === $micropetition::TYPE_QUORUM ? 'post' : 'petition']; if ($comment->getParentComment()->getUser()) { $target['comment_id'] = $comment->getId(); } $socialActivity = (new SocialActivity(SocialActivity::TYPE_FOLLOW_MICROPETITION_COMMENTED, $comment->getUser(), $micropetition->getGroup()))->setTarget($target); $this->em->persist($socialActivity); $this->em->flush($socialActivity); if ($comment->getParentComment()->getUser() && $comment->getUser() !== $comment->getParentComment()->getUser()) { $socialActivity2 = (new SocialActivity(SocialActivity::TYPE_COMMENT_REPLIED, $comment->getUser(), $micropetition->getGroup()))->setTarget($target)->setRecipient($comment->getParentComment()->getUser()); $this->em->persist($socialActivity2); $this->em->flush($socialActivity2); } }
public function getRateDown() { $this->__load(); return parent::getRateDown(); }