Example #1
0
 /**
  * @param EmailModel $emailModel
  */
 protected function initAvailableAttachments(EmailModel $emailModel)
 {
     $attachments = [];
     if ($emailModel->getParentEmailId()) {
         $parentEmail = $this->entityManager->getRepository('OroEmailBundle:Email')->find($emailModel->getParentEmailId());
         $threadAttachments = $this->emailAttachmentProvider->getThreadAttachments($parentEmail);
         $threadAttachments = $this->filterAttachmentsByName($threadAttachments);
         $attachments = array_merge($attachments, $threadAttachments);
     }
     if ($emailModel->getEntityClass() && $emailModel->getEntityId()) {
         $scopeEntity = $this->entityManager->getRepository($emailModel->getEntityClass())->find($emailModel->getEntityId());
         if ($scopeEntity) {
             $scopeEntityAttachments = $this->emailAttachmentProvider->getScopeEntityAttachments($scopeEntity);
             $scopeEntityAttachments = $this->filterAttachmentsByName($scopeEntityAttachments);
             $attachments = array_merge($attachments, $scopeEntityAttachments);
         }
     }
     $emailModel->setAttachmentsAvailable($attachments);
 }
Example #2
0
 /**
  * @param EmailModel $model
  *
  * @return string
  */
 protected function getParentMessageId(EmailModel $model)
 {
     $messageId = '';
     $parentEmailId = $model->getParentEmailId();
     if ($parentEmailId && $model->getMailType() == EmailModel::MAIL_TYPE_REPLY) {
         $parentEmail = $this->getEntityManager()->getRepository('OroEmailBundle:Email')->find($parentEmailId);
         $messageId = $parentEmail->getMessageId();
     }
     return $messageId;
 }