public function save() { foreach (self::$fields as $key => $params) { $this->settings->set($key, $this->{$key}); } $this->settings->save(); }
public function publishPaymentRequestToActivity(PaymentRequest $paymentRequest, $users = null) { if ($paymentRequest->getIsCrowdfunding()) { $activity = new ActivityCrowdfundingPaymentRequest(); $activity->setExpireAt($paymentRequest->getCrowdfundingDeadline()); } else { $activity = new ActivityPaymentRequest(); $expireDate = new \DateTime('now'); $expireDate->add(new \DateInterval('P' . $this->settings->get(Settings::DEFAULT_EXPIRE_INTERVAL)->getValue() . 'D')); $activity->setExpireAt($expireDate); } $activity->setQuestionId($paymentRequest->getId())->setTitle($paymentRequest->getTitle())->setDescription($paymentRequest->getSubject())->setSentAt($paymentRequest->getPublishedAt()); $method = 'set' . ucfirst($paymentRequest->getUser()->getType()); $activity->{$method}($paymentRequest->getUser()); $this->setImage($activity, $paymentRequest); $this->cm->addPollRootComment($paymentRequest, $paymentRequest->getTitle()); $this->entityManager->persist($activity); $this->entityManager->flush($activity); if ($users) { $this->createActivityConditionsForUsers($activity, $users); } else { $this->createActivityConditionsForQuestion($activity, $paymentRequest); } $this->pushSender->addToQueue('sendPushPublishQuestion', [$paymentRequest->getId(), "Donate: {$paymentRequest->getTitle()}"]); return $activity; }