/**
  * @param AttachmentOro $attachmentOro
  *
  * @return AttachmentModel
  */
 public function oroToModel(AttachmentOro $attachmentOro)
 {
     $attachmentModel = $this->factory->getEmailAttachment();
     $attachmentModel->setType(AttachmentModel::TYPE_ATTACHMENT);
     $attachmentModel->setId($attachmentOro->getId());
     $attachmentModel->setFileName($attachmentOro->getFile()->getOriginalFilename());
     $attachmentModel->setFileSize($attachmentOro->getFile()->getFileSize());
     $attachmentModel->setModified($attachmentOro->getCreatedAt());
     return $attachmentModel;
 }
Ejemplo n.º 2
0
 /**
  * @param EmailModel  $emailModel
  * @param EmailEntity $emailEntity
  */
 protected function applyAttachments(EmailModel $emailModel, EmailEntity $emailEntity)
 {
     try {
         $this->helper->ensureEmailBodyCached($emailEntity);
         foreach ($emailEntity->getEmailBody()->getAttachments() as $attachment) {
             $attachmentModel = $this->factory->getEmailAttachment();
             $attachmentModel->setId($attachment->getId());
             $attachmentModel->setType(EmailAttachment::TYPE_EMAIL_ATTACHMENT);
             $attachmentModel->setEmailAttachment($attachment);
             $emailModel->addAttachment($attachmentModel);
         }
     } catch (\Exception $e) {
         // maybe show notice to a user that attachments could not be loaded
     }
 }