Esempio n. 1
0
 public function load(ObjectManager $manager)
 {
     //Estos valores sólo se volcarán en el entorno de test
     if ($this->container->get('kernel')->getEnvironment() == 'test') {
         $emailLayout = new EmailLayout();
         $emailLayout->setCreationDate(Util::getCurrentDate());
         $emailLayout->setHeader('Test Header');
         $emailLayout->setFooter('Test Footer');
         $emailLayout->setName('Layout Test 1');
         $manager->persist($emailLayout, $manager);
     }
     $manager->flush();
 }
Esempio n. 2
0
 /**
  * Permite validar y almacenar la informacion de un layout
  * @author Cesar Giraldo - Kijho Technologies <*****@*****.**> 10/11/2015
  * @param Request $request datos de la solicitud
  * @return Response en caso de exito redirecciona al listado de layouts, 
  * en caso de error despliega nuevamente el formulario de creacion de layouts
  */
 public function saveAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $layoutStorage = $this->container->getParameter('kijho_mailer.storage')['layout'];
     $layout = new $layoutStorage();
     $form = $this->createForm(new EmailLayoutType($this->container), $layout);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $layout->setCreationDate(Util::getCurrentDate());
         $em->persist($layout);
         $em->flush();
         $this->get('session')->getFlashBag()->add('messageSuccessLayout', $this->get('translator')->trans('kijho_mailer.layout.creation_success_message'));
         return $this->redirect($this->generateUrl('kijho_mailer_layout'));
     }
     return $this->render('KijhoMailerBundle:Layout:new.html.twig', array('layout' => $layout, 'form' => $form->createView(), 'menu' => 'layouts'));
 }
 /**
  * Permite validar y almacenar la informacion de un template
  * @author Cesar Giraldo - Kijho Technologies <*****@*****.**> 11/11/2015
  * @param Request $request datos de la solicitud
  * @return Response en caso de exito redirecciona al listado de templates, 
  * en caso de error despliega nuevamente el formulario de creacion de templates
  */
 public function saveAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $templateStorage = $this->container->getParameter('kijho_mailer.storage')['template'];
     $template = new $templateStorage();
     $entities = $this->getReflectedProjectEntities();
     $form = $this->createForm(new EmailTemplateType($this->container, $entities['instances']), $template);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $template->setCreationDate(Util::getCurrentDate());
         $em->persist($template);
         $em->flush();
         $this->get('session')->getFlashBag()->add('messageSuccessTemplate', $this->get('translator')->trans('kijho_mailer.template.creation_success_message'));
         return $this->redirect($this->generateUrl('kijho_mailer_template'));
     }
     return $this->render('KijhoMailerBundle:Template:new.html.twig', array('template' => $template, 'form' => $form->createView(), 'entities' => $entities, 'menu' => 'templates'));
 }
 /**
  * Permite validar y almacenar la informacion de un template group
  * @author Cesar Giraldo - Kijho Technologies <*****@*****.**> 12/11/2015
  * @param Request $request datos de la solicitud
  * @return Response en caso de exito redirecciona al listado de template groups, 
  * en caso de error despliega nuevamente el formulario de creacion de template groups
  */
 public function saveAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $templateGroupStorage = $this->container->getParameter('kijho_mailer.storage')['template_group'];
     $templateGroup = new $templateGroupStorage();
     $form = $this->createForm(new EmailTemplateGroupType($this->container), $templateGroup);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $templateGroup->setCreationDate(Util::getCurrentDate());
         $em->persist($templateGroup);
         $em->flush();
         //Seteamos el slug del grupo
         $slug = trim(strtolower(str_replace(' ', '_', $templateGroup->getName()))) . "_" . $templateGroup->getId();
         $templateGroup->setSlug($slug);
         $em->persist($templateGroup);
         $em->flush();
         $this->get('session')->getFlashBag()->add('messageSuccessTemplateGroup', $this->get('translator')->trans('kijho_mailer.template_group.creation_success_message'));
         return $this->redirect($this->generateUrl('kijho_mailer_template_group'));
     }
     return $this->render('KijhoMailerBundle:TemplateGroup:new.html.twig', array('templateGroup' => $templateGroup, 'form' => $form->createView(), 'menu' => 'templateGroups'));
 }
Esempio n. 5
0
 /**
  * Esta funcion permite inicializar los datos de un correo electronico
  * @author Cesar Giraldo <*****@*****.**> 23/11/2015
  * @param Template $template instancia del template medianete el cual se envia el correo
  * @param string $emailAddress direcion(es) de correo electronico
  * @return \Kijho\MailerBundle\Model\Email
  */
 public function composeEmail(Template $template, $emailAddress)
 {
     $emailStorage = $this->container->getParameter('kijho_mailer.storage')['email'];
     $email = new $emailStorage();
     $email->setTemplate($template);
     $email->setContent($template->getContentMessage());
     $email->setFromName($template->getFromName());
     $email->setGeneratedDate(Util::getCurrentDate());
     $email->setMailCopyTo($template->getCopyTo());
     $email->setMailFrom($template->getFromMail());
     //filtramos la direccion de correo para saber si vienen varias direcciones en una
     $emailAddress = $this->buildArrayEmails($emailAddress);
     $email->setMailTo(json_encode($emailAddress));
     $email->setStatus(Email::STATUS_PENDING);
     $email->setSubject($template->getSubject());
     return $email;
 }