示例#1
0
 public function serializeMessage(EmailMessage $message)
 {
     // Make the email being sent to available to the templates
     $data = array_merge($message->getData(), array('to' => array(array('email' => $message->getEmail(), 'type' => 'to')), 'subject' => $message->getSubjectLine(), '_message_id' => $message->getId(), 'headers' => array()));
     $data['html'] = $this->templating->render(sprintf('ForexEmailBundle:%s.html.twig', $message->getTemplate()), $data);
     $data['text'] = $this->templating->render(sprintf('ForexEmailBundle:%s.text.twig', $message->getTemplate()), $data);
     $data['from_email'] = array_key_exists('from', $data) ? $data['from'] : '*****@*****.**';
     if ($message->getReplyTo()) {
         $data['headers']['Reply-To'] = $message->getReplyTo();
     }
     if ($message->getCcEmail()) {
         $data['to'][] = array('email' => $message->getCcEmail(), 'type' => 'cc');
     }
     if ($message->getBccEmail()) {
         $data['to'][] = array('email' => $message->getBccEmail(), 'type' => 'bcc');
     }
     return $data;
 }