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; }
/** * @param Petition $petition * @param bool $saveTagsInEntity */ public function addForPetition(Petition $petition, $saveTagsInEntity = true) { $em = $this->getEntityManager(); $tags = HashTagParser::parseHashTags($petition->getPetitionBody()); foreach ($tags['parsed'] as $tag) { $entity = $this->findOneByName($tag); if (!$entity) { $entity = new HashTag($tag); $em->persist($entity); } $entity->addPetition($petition); $em->flush($entity); } if ($saveTagsInEntity) { $petition->setCachedHashTags($tags['original']); $em->flush($petition); } }
public function getPetitionBody() { $this->__load(); return parent::getPetitionBody(); }