protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var EntityManager $em */
     $this->em = $this->getContainer()->get('doctrine')->getManager();
     $section_id = $input->getArgument('section_id');
     if ($section_id) {
         $this->section = $this->em->getRepository('BuddySystemMainBundle:Section')->find($section_id);
     }
     if ($this->section) {
         $output->writeln('<comment>Section given : ' . $this->section->getName() . '</comment>');
     } else {
         $output->writeln('<error>The given section is wrong</error>');
         exit;
     }
     $this->addEmail($output, "Bienvenue dans le BuddySystem", '../../UserBundle/Resources/views/Mails/mailToLocal.txt.twig', 'welcome_local');
     $this->addEmail($output, "Welcome in the BuddySystem", '../../UserBundle/Resources/views/Mails/mailToIS.txt.twig', 'welcome_is');
     $this->addEmail($output, "You have been matched !", '../../MatchingBundle/Resources/views/Mail/mailToBuddy.txt.twig', 'matched_is');
     $this->addEmail($output, "Nous vous avons trouvé quelqu'un !", '../../MatchingBundle/Resources/views/Mail/mailToLocal.txt.twig', 'matched_local');
     $this->addEmail($output, "Password Reset", '../../UserBundle/Resources/views/Mails/mailReset.txt.twig', 'reset');
 }
 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;
 }
 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;
 }