Ojs\JournalBundle\Entity\MailTemplate::setLang PHP Метод

setLang() публичный Метод

Set lang
public setLang ( string $lang ) : MailTemplate
$lang string
Результат MailTemplate
    public function setLang($lang)
    {
        $this->lang = $lang;
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * @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()));
 }