public function sendWelcomeEmail(User $user)
 {
     $token = $this->tokenGenerator->generateToken();
     $link = $this->router->generate('fos_user_registration_register', array('token' => $token), true);
     $this->mailer->sendMail($this->translator->trans('jwkh.publishers.email.welcome.subject', array(), null, $user->getPublisher()->getCongregation()->getDefaultLocale()), '*****@*****.**', $user->getEmail(), $this->translator->trans('jwkh.publishers.email.welcome.body', array('%link%' => $link), null, $user->getPublisher()->getCongregation()->getDefaultLocale()));
     $user->setConfirmationToken($token);
     $this->userManager->updateUser($user);
 }
 /**
  * process a task
  *
  * @param integer $jobId the id of the job being processed
  * @param array $parameters an array of parameters
  *
  * @throws TaskException
  * @return void
  */
 public function process($jobId, $parameters = array())
 {
     $territories = $this->entityManager->getRepository('KingdomHallDataBundle:Territory')->findAll();
     $tNotifs = array_filter($territories, function (Territory $territory) {
         return $territory->getStatus() == Territory::TERRITORY_STATUS_WARNING || $territory->getStatus() == Territory::TERRITORY_STATUS_ALERT;
     });
     /** @var Territory $territory */
     foreach ($tNotifs as $territory) {
         if ($territory->getPublisher()->getEmail() && $territory->getNotified() != $territory->getStatus()) {
             $settings = $territory->getCongregation()->getSettings();
             $alertDate = clone $territory->getBorrowDate();
             $alertDate->add(\DateInterval::createFromDateString('+' . $settings->get('territory_max_borrow_time')->getValue()));
             $this->mailer->sendMail($this->translator->trans('jwkh.territories.email.' . $territory->getStatus() . '.subject', array('%number%' => $territory->getNumber() . ' - ' . $territory->getName()), null, $territory->getCongregation()->getDefaultLocale()), '*****@*****.**', $territory->getPublisher()->getEmail(), $this->translator->trans('jwkh.territories.email.' . $territory->getStatus() . '.body', array('%firstName%' => $territory->getPublisher()->getFirstName(), '%number%' => $territory->getNumber() . ' - ' . $territory->getName(), '%date%' => $alertDate->format($settings->get('date_format_twig')->getValue())), null, $territory->getCongregation()->getDefaultLocale()));
             $territory->setNotified($territory->getStatus());
             $this->entityManager->persist($territory);
             $this->entityManager->flush();
         }
     }
 }