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();
 }
 /**
  * @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>');
     }
 }