예제 #1
0
 public function storeQuestion(Question $question)
 {
     if ($question) {
         $question->setCreatedAt(new DateTime());
         $this->getDocumentManager()->persist($question);
         $this->getDocumentManager()->flush();
         return $question;
     }
     return false;
 }
예제 #2
0
 /**
  * @param Question $question
  * @return bool
  */
 public function sendConfirmationToUser(Question $question)
 {
     $token = hash('md5', $this->container->getParameter('secret') . $question->getEmail());
     $router = $this->container->get('router');
     $questionDetail = $router->generate('detailQuestion', ['email' => $question->getEmail(), 'token' => $token]);
     /** @var \Swift_Message $message */
     $message = \Swift_Message::newInstance()->setSubject('Nový dotaz')->setFrom('*****@*****.**')->setTo($question->getEmail())->setBody($this->engine->render('VirtualniNemocniceAppBundle:Email:emailToPatient.html.twig', ['patient' => $question, 'questionDetail' => $questionDetail]), 'text/html');
     try {
         $this->container->get('mailer')->send($message);
         $this->logger->info('Email sent to user email: ' . $question->getEmail());
         return true;
     } catch (\Exception $e) {
         $this->logger->error('Email not sent to user email: ' . $question->getEmail() . ', ' . $e->getMessage(), ['exception' => $e]);
     }
     return false;
 }