Пример #1
0
 /**
  * Renders the google analytics tracking code.
  *
  * @return string
  */
 public function getGoogleTracking()
 {
     /** @var \Ekyna\Bundle\GoogleBundle\Model\TrackingCode $trackingCode */
     $trackingCode = $this->settingManager->getParameter('google.tracking_code');
     if (!$this->debug && 0 < strlen($trackingCode->getPropertyId())) {
         $domain = $trackingCode->getDomain();
         if (0 === strlen($domain)) {
             $domain = 'auto';
         }
         if (in_array($trackingCode->getDomain(), ['none', 'auto'])) {
             $domain = sprintf("'%s'", $domain);
         } else {
             $domain = sprintf("{'cookieDomain': '%s'}", $domain);
         }
         return sprintf(self::GA_TRACKING_CODE, $trackingCode->getPropertyId(), $domain);
     }
     return '';
 }
Пример #2
0
 /**
  * Sends the "call user for payment" email.
  *
  * @param UserInterface $user
  * @return bool
  */
 public function sendCallUserForPayment(UserInterface $user)
 {
     /** @var \Ekyna\Bundle\SubscriptionBundle\Model\SubscriptionInterface[] $subscriptions */
     $subscriptions = $this->getSubscriptionRepository()->findByUserAndPaymentRequired($user);
     if (empty($subscriptions)) {
         return true;
     }
     $fromEmail = $this->settings->getParameter('notification.from_email');
     $fromName = $this->settings->getParameter('notification.from_name');
     $content = $this->templating->render($this->config['templates']['call_user_for_payment'], array('user' => $user, 'subscriptions' => $subscriptions));
     $message = \Swift_Message::newInstance();
     $message->setFrom($fromEmail, $fromName)->setTo($user->getEmail(), (string) $user)->setSubject($this->translator->trans('ekyna_subscription.email.call_user_for_payment.subject'))->setBody($content, 'text/html');
     if (0 < $this->mailer->send($message)) {
         foreach ($subscriptions as $subscription) {
             $subscription->setNotifiedAt(new \DateTime());
             $this->em->persist($subscription);
         }
         $this->em->flush();
         return true;
     }
     return false;
 }