Esempio n. 1
0
 /**
  * Translate the given string if there is a translator service available.
  *
  * @param $string
  * @param $replacements
  * @param $context
  * @return mixed
  */
 public function t($string, $replacements = array(), $context = array())
 {
     // If there is no translation service available use a passthrough to send
     // back the original (en-us) string.
     if (empty($this->translator)) {
         $this->translator = new PassthroughTranslator();
     }
     return $this->translator->translate($string, $replacements, $context);
 }
Esempio n. 2
0
 public function sendForgotManageLinkMail($email)
 {
     $results = $this->em->getRepository('IntractoSecretSantaBundle:Pool')->findAllAdminPools($email);
     if (count($results) == 0) {
         return false;
     }
     $poolLinks = array();
     foreach ($results as $result) {
         $text = $this->translator->trans('manage.title');
         if ($result['date'] instanceof \DateTime) {
             $text .= ' (' . $result['date']->format('d/m/Y') . ')';
         }
         $poolLinks[] = array('url' => $this->routing->generate('pool_manage', array('listUrl' => $result['listurl']), Router::ABSOLUTE_URL), 'text' => $text);
     }
     $this->translator->setLocale($results[0]['locale']);
     $message = \Swift_Message::newInstance()->setSubject($this->translator->trans('emails.forgot_link.subject'))->setFrom($this->adminEmail, $this->translator->trans('emails.sender'))->setTo($email)->setBody($this->templating->render('IntractoSecretSantaBundle:Emails:forgotlink.txt.twig', array('poolLinks' => $poolLinks)))->addPart($this->templating->render('IntractoSecretSantaBundle:Emails:forgotlink.html.twig', array('poolLinks' => $poolLinks)), 'text/html');
     $this->mailer->send($message);
     return true;
 }
Esempio n. 3
0
 /**
  * @param Pool $pool
  */
 public function sendPoolMatchesToAdmin(Pool $pool)
 {
     $this->translator->setLocale($pool->getLocale());
     $this->mailer->send(\Swift_Message::newInstance()->setSubject($this->translator->trans('emails.admin_matches.subject'))->setFrom($this->adminEmail, $this->translator->trans('emails.sender'))->setTo($pool->getOwnerEmail(), $pool->getOwnerName())->setBody($this->templating->render('IntractoSecretSantaBundle:Emails:admin_matches.html.twig', array('pool' => $pool)), 'text/html')->addPart($this->templating->render('IntractoSecretSantaBundle:Emails:admin_matches.txt.twig', array('pool' => $pool)), 'text/plain'));
 }