Inheritance: implements Gedmo\Translatable\Translatable, use trait Ojs\Common\Entity\GenericEntityTrait
 private function createJournalMailTemplates(Journal $journal, OutputInterface $output)
 {
     $container = $this->getContainer();
     $yamlParser = new Parser();
     $defaultTemplates = $yamlParser->parse(file_get_contents($container->getParameter('kernel.root_dir') . '/../src/Ojs/CoreBundle/Resources/data/mailtemplates.yml'));
     foreach ($defaultTemplates as $template) {
         $newTemplate = new MailTemplate();
         $newTemplate->setJournal($journal)->setLang($template['lang'])->setTemplate($template['template'])->setSubject($template['subject'])->setType($template['type']);
         $this->em->persist($newTemplate);
         $output->writeln('Persisted the mail template ' . $template['subject']);
     }
     $this->em->flush();
 }
 /**
  * @param  Request                   $request
  * @param $id
  * @return RedirectResponse|Response
  */
 public function copyAction(Request $request, $id)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('CREATE', $journal, 'mailTemplate')) {
         throw new AccessDeniedException("You are not authorized for view this page!");
     }
     $entity = new MailTemplate();
     $yamlParser = new Parser();
     $defaultTemplates = $yamlParser->parse(file_get_contents($this->container->getParameter('kernel.root_dir') . '/../src/Ojs/JournalBundle/Resources/data/mailtemplates.yml'));
     $template = [];
     foreach ($defaultTemplates as $temp) {
         if ($temp['id'] == $id) {
             $template = $temp;
             break;
         }
     }
     $entity->setLang($template['lang'])->setSubject($template['subject'])->setTemplate(str_replace('<br>', "\n", $template['template']))->setType($template['type'])->setJournal($journal);
     $form = $this->createCreateForm($entity, $journal->getId());
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('ojs_journal_mail_template_show', array('id' => $entity->getId(), 'journalId' => $journal->getId())));
     }
     return $this->render('OjsJournalBundle:MailTemplate:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
示例#3
0
 /**
  * @param MailTemplate $mailTemplate
  * @return null|object|MailTemplate
  */
 private function getDefaultMailTemplate(MailTemplate $mailTemplate)
 {
     $em = $this->getDoctrine()->getManager();
     $GLOBALS['Ojs\\JournalBundle\\Entity\\MailTemplate#journalFilter'] = false;
     return $em->getRepository('OjsJournalBundle:MailTemplate')->findOneBy(['type' => $mailTemplate->getType(), 'journal' => null, 'journalDefault' => true, 'lang' => $this->getParameter('locale')]);
 }
示例#4
0
 /**
  * @param EventDetail $eventOptions
  * @param string $lang
  * @param Journal|null $journal
  * @param bool $journalDefault
  * @param bool $useJournalDefault
  * @param bool $active
  */
 private function createMailTemplateSkeleton(EventDetail $eventOptions, $lang = 'en', Journal $journal = null, $journalDefault = false, $useJournalDefault = true, $active = true)
 {
     $this->io->writeln(sprintf('Creating template for -> %s -> %s', $eventOptions->getName(), $journal == null ? 'admin' : $journal->getTitle()));
     $mailTemplate = new MailTemplate();
     $mailTemplate->setActive($active)->setJournal($journal)->setType($eventOptions->getName())->setLang($lang)->setTemplate('')->setUseJournalDefault($useJournalDefault)->setJournalDefault($journalDefault)->setUpdatedBy('cli');
     $this->em->persist($mailTemplate);
 }