/** * @param OutputInterface $output * @param $subject * @param $path * @param $key */ private function addEmail(OutputInterface $output, $subject, $path, $key) { $now = new DateTime('now'); $email = new Emails(); $email->setSubject($subject); $email->setPath($path); $email->setBody(file_get_contents(__DIR__ . '/' . $email->getPath(), FILE_USE_INCLUDE_PATH)); $email->setSection($this->section); $email->setUpdated($now->format('H:i:s d-m-Y')); $email->setKey($key); /** @var Emails $email_db */ $email_db = $this->em->getRepository('BuddySystemMembersBundle:Emails')->findOneBy(array("key" => $key, "section" => $this->section)); if (!$email_db) { $output->writeln('<comment>Email: ' . $email->getSubject() . ' added</comment>'); $this->em->persist($email); $this->em->flush(); } else { $output->writeln('<error>Email already exist</error>'); } }
private function initEmails() { $em = $this->getDoctrine()->getManager(); $sectionManager = $this->container->get('section_manager'); $section = $sectionManager->getCurrentSection(); $now = new \DateTime(); $email = new Emails(); $email->setSubject("Bienvenue dans le BuddySystem"); $email->setPath('../src/BuddySystem/UserBundle/Resources/views/Mails/mailToLocal.txt.twig'); $email->setBody(file_get_contents($email->getPath(), FILE_USE_INCLUDE_PATH)); $email->setSection($section); $email->setUpdated($now->format('H:i:s d-m-Y')); $email->setKey('welcome_local'); $em->persist($email); $em->flush(); $email = new Emails(); $email->setSubject("Welcome in the BuddySystem"); $email->setPath('../src/BuddySystem/UserBundle/Resources/views/Mails/mailToIS.txt.twig'); $email->setBody(file_get_contents($email->getPath(), FILE_USE_INCLUDE_PATH)); $email->setSection($section); $email->setUpdated($now->format('H:i:s d-m-Y')); $email->setKey('welcome_is'); $em->persist($email); $em->flush(); $email = new Emails(); $email->setSubject("You have been matched !"); $email->setPath('../src/BuddySystem/MatchingBundle/Resources/views/Mail/mailToBuddy.txt.twig'); $email->setBody(file_get_contents($email->getPath(), FILE_USE_INCLUDE_PATH)); $email->setSection($section); $email->setUpdated($now->format('H:i:s d-m-Y')); $email->setKey('matched_is'); $em->persist($email); $em->flush(); $email = new Emails(); $email->setSubject("Nous vous avons trouvé quelqu'un !"); $email->setPath('../src/BuddySystem/MatchingBundle/Resources/views/Mail/mailToLocal.txt.twig'); $email->setBody(file_get_contents($email->getPath(), FILE_USE_INCLUDE_PATH)); $email->setSection($section); $email->setUpdated($now->format('H:i:s d-m-Y')); $email->setKey('matched_local'); $em->persist($email); $em->flush(); }
public function replace_keys(Emails $mail, User $local, User $is, Section $section) { $mail->setBody(str_replace('local.prenom', $local->getPrenom(), $mail->getBody())); $mail->setBody(str_replace('is_student.prenom', $is->getPrenom(), $mail->getBody())); $mail->setBody(str_replace('local.nom', $local->getNom(), $mail->getBody())); $mail->setBody(str_replace('is_student.nom', $is->getNom(), $mail->getBody())); $mail->setBody(str_replace('local.age', $local->getAge(), $mail->getBody())); $mail->setBody(str_replace('is_student.age', $is->getAge(), $mail->getBody())); $mail->setBody(str_replace('local.universite', $local->getUniversite(), $mail->getBody())); $mail->setBody(str_replace('is_student.universite', $is->getUniversite(), $mail->getBody())); if ($local->getArrival() != null) { $mail->setBody(str_replace('local.arrival', $local->getArrival()->format('d/m/Y'), $mail->getBody())); } if ($is->getArrival() != null) { $mail->setBody(str_replace('is_student.arrival', $is->getArrival()->format('d/m/Y'), $mail->getBody())); } else { $mail->setBody(str_replace(' et arrivera le is_student.arrival.', '.', $mail->getBody())); } $mail->setBody(str_replace('local.email', $local->getEmail(), $mail->getBody())); $mail->setBody(str_replace('is_student.email', $is->getEmail(), $mail->getBody())); $mail->setBody(str_replace('local.username', $local->getUsername(), $mail->getBody())); $mail->setBody(str_replace('is_student.username', $is->getUsername(), $mail->getBody())); $mail->setBody(str_replace('local.password', $local->getPassword(), $mail->getBody())); $mail->setBody(str_replace('is_student.password', $is->getPassword(), $mail->getBody())); $mail->setBody(str_replace('local.nationality', $local->getNationalite(), $mail->getBody())); $mail->setBody(str_replace('is_student.nationality', $is->getNationalite(), $mail->getBody())); $mail->setBody(str_replace('section.name', $section->getName(), $mail->getBody())); return $mail; }
private function replace_keys(Emails $mail, User $is) { $mail->setBody(str_replace('is_student.prenom', $is->getPrenom(), $mail->getBody())); $mail->setBody(str_replace('is_student.nom', $is->getNom(), $mail->getBody())); $mail->setBody(str_replace('is_student.age', $is->getAge(), $mail->getBody())); $mail->setBody(str_replace('is_student.universite', $is->getUniversite(), $mail->getBody())); $mail->setBody(str_replace('is_student.email', $is->getEmail(), $mail->getBody())); $mail->setBody(str_replace('is_student.username', $is->getUsername(), $mail->getBody())); $mail->setBody(str_replace('is_student.password', $this->plainpass, $mail->getBody())); $mail->setBody(str_replace('is_student.nationality', $is->getNationalite(), $mail->getBody())); $mail->setBody(str_replace('section.name', $this->sectionManager->getCurrentSection()->getName(), $mail->getBody())); return $mail; }
private function replace_keys(Emails $mail, User $local) { $mail->setBody(str_replace('local.prenom', $local->getPrenom(), $mail->getBody())); $mail->setBody(str_replace('local.nom', $local->getNom(), $mail->getBody())); $mail->setBody(str_replace('local.age', $local->getAge(), $mail->getBody())); $mail->setBody(str_replace('local.universite', $local->getUniversite(), $mail->getBody())); $mail->setBody(str_replace('local.email', $local->getEmail(), $mail->getBody())); $mail->setBody(str_replace('local.username', $local->getUsername(), $mail->getBody())); $mail->setBody(str_replace('local.password', $this->plainpass, $mail->getBody())); $mail->setBody(str_replace('local.nationality', $local->getNationalite(), $mail->getBody())); $mail->setBody(str_replace('section.name', $this->section->getName(), $mail->getBody())); return $mail; }