Ejemplo n.º 1
0
 /**
  * Compose the email data to be sent.
  *
  * @param FormConfig  $formConfig
  * @param EmailConfig $emailConfig
  * @param FormData    $formData
  */
 private function emailCompose(FormConfig $formConfig, EmailConfig $emailConfig, FormData $formData)
 {
     /*
      * Create message object
      */
     $this->message = \Swift_Message::newInstance();
     $this->message->setEncoder(\Swift_Encoding::get8BitEncoding());
     // Set our Twig lookup path
     $this->addTwigPath();
     // If the form has it's own templates defined, use those, else the globals.
     $templateSubject = $formConfig->getTemplates()->getSubject() ?: $this->config['templates']['subject'];
     $templateEmail = $formConfig->getTemplates()->getEmail() ?: $this->config['templates']['email'];
     $fieldmap = $this->config['fieldmap']['email'];
     /*
      * Subject
      */
     $html = $this->app['render']->render($templateSubject, array($fieldmap['subject'] => $formConfig->getNotification()->getSubject(), $fieldmap['config'] => $emailConfig, $fieldmap['data'] => $formData));
     $subject = new \Twig_Markup($html, 'UTF-8');
     /*
      * Body
      */
     $html = $this->app['render']->render($templateEmail, array($fieldmap['fields'] => $formConfig->getFields(), $fieldmap['config'] => $emailConfig, $fieldmap['data'] => $this->getBodyData($emailConfig, $formData)));
     $body = new \Twig_Markup($html, 'UTF-8');
     $text = preg_replace('/<style\\b[^>]*>(.*?)<\\/style>/s', '', $body);
     /*
      * Build email
      */
     $this->message->setSubject($subject)->setBody(strip_tags($text))->addPart($body, 'text/html');
 }
 /**
  * Do a redirect.
  *
  * @param FormConfig $formConfig
  * @param FormData   $formData
  */
 public function redirect(FormConfig $formConfig, FormData $formData)
 {
     $redirect = $formConfig->getFeedback()->getRedirect();
     $query = $this->getRedirectQuery($redirect, $formData);
     $response = $this->getRedirectResponse($redirect, $query);
     if ($response instanceof RedirectResponse) {
         $response->send();
     }
 }
Ejemplo n.º 3
0
 /**
  * Get resolved email configuration settings.
  */
 private function setEmailConfig()
 {
     $notify = $this->formConfig->getNotification();
     $hashMap = array('fromName' => 'from_name', 'fromEmail' => 'from_email', 'replyToName' => 'replyto_name', 'replyToEmail' => 'replyto_email', 'toName' => 'to_name', 'toEmail' => 'to_email', 'ccName' => 'cc_name', 'ccEmail' => 'cc_email', 'bccName' => 'bcc_name', 'bccEmail' => 'bcc_email');
     foreach ($hashMap as $property => $key) {
         $this->{$property} = $this->getConfigValue($notify->{$key});
     }
 }
Ejemplo n.º 4
0
 /**
  * Redirect if a redirect is set and the page exists
  *
  * @param FormConfig $formConfig
  * @param FormData   $formData
  */
 protected function processRedirect(FormConfig $formConfig, FormData $formData)
 {
     if ($formConfig->getFeedback()->redirect['target'] !== null) {
         $redirect = new RedirectHandler($this->app['url_matcher']);
         $redirect->redirect($formConfig, $formData);
     }
 }
Ejemplo n.º 5
0
 /**
  * Redirect if a redirect is set and the page exists
  *
  * @param FormConfig $formConfig
  * @param FormData   $formData
  */
 protected function processRedirect(FormConfig $formConfig, FormData $formData)
 {
     if ($formConfig->getFeedback()->redirect['target'] === null) {
         $formConfig->getFeedback()->redirect = array('target' => $this->app['request']->getPathInfo(), 'query' => $formConfig->getFeedback()->redirect['query']);
     }
     $redirect = new RedirectHandler($this->app['url_matcher']);
     $redirect->redirect($formConfig, $formData);
 }