Exemplo n.º 1
0
 public function publishMicroPetitionToActivity(MicroPetition $petition, $isPublic = false)
 {
     //update petition
     if ($isPublic) {
         $expireDate = new \DateTime('now');
         $expireDate->add(new \DateInterval('P' . $petition->getUserExpireInterval() . 'D'));
         $petition->setExpireAt($expireDate);
         $petition->setPublishStatus(MicroPetition::STATUS_PUBLISH);
         $this->entityManager->persist($petition);
     }
     //create activity
     $activity = new ActivityMicroPetition();
     $activity->setPetitionId($petition->getId());
     $activity->setTitle('');
     if ($petition->getType() === MicroPetition::TYPE_LONG_PETITION) {
         $activity->setTitle($petition->getTitle());
         $activity->setDescription($petition->getPetitionBody());
     } else {
         $activity->setDescription($petition->getPetitionBody());
     }
     $activity->setSentAt(new \DateTime());
     $activity->setExpireAt($petition->getExpireAt());
     $activity->setResponsesCount($petition->getAnswers()->count());
     $activity->setIsOutsiders($petition->getIsOutsidersSign());
     $activity->setGroup($petition->getGroup());
     $activity->setQuorum($petition->getQuorumCount());
     if (!$isPublic) {
         $activity->setUser($petition->getUser());
     }
     $this->entityManager->persist($activity);
     $this->entityManager->flush();
     $this->createActivityConditionsForMicroPetition($activity, $petition);
     if ($isPublic) {
         $this->pushSender->addToQueue('sendGroupPetitionPush', [$petition->getGroup()->getId(), $petition->getId()]);
     }
     return true;
 }
 public function getActivityImage()
 {
     $this->__load();
     return parent::getActivityImage();
 }