/** * @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); }