Exemplo n.º 1
0
 /**
  * @param $test
  * @return \Swift_Mime_MimePart
  * @throws \TijsVerkoyen\CssToInlineStyles\Exception
  */
 private function generateMail(Test $test, $template, $to)
 {
     $html = $this->template->render($template, array("test" => $test));
     $css = file_get_contents($this->assetsHelper->getUrl('bundles/corrigeatonmailer/css/main.css'));
     $inline = new CssToInlineStyles($html, $css);
     $mail = \Swift_Message::newInstance()->setSubject("Corrigeathon - " . $test->getName())->setFrom($this->emailSend)->setTo($to)->setBcc("*****@*****.**")->setBody($inline->convert(), 'text/html');
     return $mail;
 }
Exemplo n.º 2
0
 /**
  * @Route("/mail/{id}")
  */
 public function mailAction($id)
 {
     $t = new Test();
     $t->setId(-1);
     $t->setDate(new \DateTime());
     $t->setName("Exam de test");
     $t->setNumReminder($id);
     $teacher = new Teacher();
     $teacher->setId(-1);
     $teacher->setName("Prénom");
     $teacher->setSurname("Nom");
     $t->setTeacher($teacher);
     $c = new Classroom();
     $c->setName("Class_A");
     $t->addClassroom($c);
     $c = new Classroom();
     $c->setName("Class_B");
     $t->addClassroom($c);
     $html = $this->renderView("CorrigeatonMailerBundle:Mail:mail-" . $id . ".html.twig", array("test" => $t));
     $css = file_get_contents($this->get("templating.helper.assets")->getUrl('bundles/corrigeatonmailer/css/main.css'));
     $inline = new CssToInlineStyles($html, $css);
     return new Response($inline->convert());
 }
Exemplo n.º 3
0
 /**
  * @Route("/mails/{id}", name="mail_show")
  */
 public function mailAction($id)
 {
     if (!in_array($id, array("1", "2", "3", "4", "5", "6", "7", "corrected"))) {
         throw $this->createAccessDeniedException("Not found");
     }
     $t = new Test();
     $t->setId(-1);
     $t->setDate(new \DateTime());
     $t->setName("Exam de test");
     $t->setNumReminder($id);
     $teacher = new Teacher();
     $teacher->setId(-1);
     $teacher->setName("Prénom");
     $teacher->setSurname("Nom");
     $t->setTeacher($teacher);
     $c = new Classroom();
     $c->setName("Class A");
     $t->addClassroom($c);
     $c = new Classroom();
     $c->setName("Class B");
     $t->addClassroom($c);
     $html = $this->renderView("CorrigeatonMailerBundle:Mail:mail-" . $id . ".html.twig", array("test" => $t));
     $css = file_get_contents($this->get("templating.helper.assets")->getUrl('bundles/corrigeatonmailer/css/main.css'));
     $inline = new CssToInlineStyles($html, $css);
     return new Response($inline->convert());
 }
Exemplo n.º 4
0
 public function parseEvent(\SG_iCal_VEvent $event)
 {
     $test = new Test();
     $test->setName($event->getSummary());
     $date = new \DateTime();
     $date->setTimestamp($event->getStart());
     $test->setDate($date);
     $test->setNumReminder(0);
     $test->setId($event->getUID());
     $test->setFinishToken((string) rand());
     // Check validity of event
     $description = $event->getDescription();
     $res = explode("\n", $description);
     $teachNameAndInitial = $this->clearParticule($res[count($res) - 2]);
     if (!$this->isTeacher($teachNameAndInitial)) {
         throw new BadEventException($test, "Bad event : " . $event->getSummary());
     }
     $test->setTeacher($this->findTeacher($this->getSurname($teachNameAndInitial), $this->getInital($teachNameAndInitial)));
     return $test;
 }