/**
  * @param EmailBodyLoaded $event
  */
 public function replace(EmailBodyLoaded $event)
 {
     $emailBody = $event->getEmail()->getEmailBody();
     if ($emailBody !== null) {
         $content = $emailBody->getBodyContent();
         $attachments = $emailBody->getAttachments();
         $replacements = [];
         if (!$emailBody->getBodyIsText()) {
             foreach ($attachments as $attachment) {
                 $contentId = $attachment->getEmbeddedContentId();
                 if ($contentId !== null && $this->supportsAttachment($attachment)) {
                     $replacement = sprintf('data:%s;base64,%s', $attachment->getContentType(), $attachment->getContent()->getContent());
                     $replacements['cid:' . $contentId] = $replacement;
                 }
             }
             $emailBody->setBodyContent(strtr($content, $replacements));
         }
     }
 }
Ejemplo n.º 2
0
 public function testConstruct()
 {
     $email = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Email')->disableOriginalConstructor()->getMock();
     $emailBodySyncAfter = new EmailBodyLoaded($email);
     $this->assertEquals($emailBodySyncAfter->getEmail(), $email);
 }