public function noticeMicropetitionCreated(Micropetition $micropetition) { $socialActivity = (new SocialActivity(SocialActivity::TYPE_GROUP_POST_CREATED, $micropetition->getUser(), $micropetition->getGroup()))->setTarget(['id' => $micropetition->getId(), 'title' => $micropetition->getTitle(), 'type' => $micropetition->getType(), 'body' => $micropetition->getPetitionBody()]); $this->em->persist($socialActivity); $this->em->flush($socialActivity); $this->pt->addToQueue('sendSocialActivity', [$socialActivity->getId()]); return $socialActivity; }
/** * Check count answers from group of petition. If it greater than 10% group's followers * than need to publish to actitvity * * @param \Civix\CoreBundle\Entity\Micropetitions\Petition $petition * * @return boolean */ public function checkIfNeedPublish(UserPetition $petition) { if ($petition->getType() === $petition::TYPE_OPEN_LETTER) { return false; } $groupAnswers = $this->entityManager->getRepository('CivixCoreBundle:Micropetitions\\Answer')->getCountAnswerFromGroup($petition); return $groupAnswers >= $petition->getQuorumCount(); }
public function getType() { $this->__load(); return parent::getType(); }