From 4859f54f42af3fa0baaf1dad44fd2ea17f89ea8a Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 1 Aug 2016 10:16:09 +0300 Subject: [PATCH] email import: get rid of file manager --- application/Espo/Core/Mail/Importer.php | 15 ++------------- application/Espo/Services/EmailAccount.php | 8 +------- application/Espo/Services/InboundEmail.php | 8 +------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/application/Espo/Core/Mail/Importer.php b/application/Espo/Core/Mail/Importer.php index 2108b9d6d4..54bffd46c1 100644 --- a/application/Espo/Core/Mail/Importer.php +++ b/application/Espo/Core/Mail/Importer.php @@ -38,16 +38,13 @@ class Importer { private $entityManager; - private $fileManager; - private $config; private $filtersMatcher; - public function __construct($entityManager, $fileManager, $config) + public function __construct($entityManager, $config) { $this->entityManager = $entityManager; - $this->fileManager = $fileManager; $this->config = $config; $this->filtersMatcher = new FiltersMatcher(); } @@ -62,11 +59,6 @@ class Importer return $this->config; } - protected function getFileManager() - { - return $this->fileManager; - } - protected function getFiltersMatcher() { return $this->filtersMatcher; @@ -475,13 +467,10 @@ class Importer $content = base64_decode($content); } - $attachment->set('size', strlen($content)); + $attachment->set('contents', $content); $this->getEntityManager()->saveEntity($attachment); - $path = $this->getEntityManager()->getRepository('Attachment')->getFilePath($attachment); - $this->getFileManager()->putContents($path, $content); - if ($disposition == 'attachment') { $attachmentsIds = $email->get('attachmentsIds'); $attachmentsIds[] = $attachment->id; diff --git a/application/Espo/Services/EmailAccount.php b/application/Espo/Services/EmailAccount.php index 6650795ad9..d30424b187 100644 --- a/application/Espo/Services/EmailAccount.php +++ b/application/Espo/Services/EmailAccount.php @@ -45,15 +45,9 @@ class EmailAccount extends Record protected function init() { - $this->dependencies[] = 'fileManager'; $this->dependencies[] = 'crypt'; } - protected function getFileManager() - { - return $this->injections['fileManager']; - } - protected function getCrypt() { return $this->injections['crypt']; @@ -181,7 +175,7 @@ class EmailAccount extends Record throw new Error(); } - $importer = new \Espo\Core\Mail\Importer($this->getEntityManager(), $this->getFileManager(), $this->getConfig()); + $importer = new \Espo\Core\Mail\Importer($this->getEntityManager(), $this->getConfig()); $maxSize = $this->getConfig()->get('emailMessageMaxSize'); diff --git a/application/Espo/Services/InboundEmail.php b/application/Espo/Services/InboundEmail.php index c92e1f4311..fd8f399d33 100644 --- a/application/Espo/Services/InboundEmail.php +++ b/application/Espo/Services/InboundEmail.php @@ -70,16 +70,10 @@ class InboundEmail extends \Espo\Services\Record protected function init() { - $this->dependencies[] = 'fileManager'; $this->dependencies[] = 'mailSender'; $this->dependencies[] = 'crypt'; } - protected function getFileManager() - { - return $this->injections['fileManager']; - } - protected function getMailSender() { return $this->injections['mailSender']; @@ -158,7 +152,7 @@ class InboundEmail extends \Espo\Services\Record throw new Error(); } - $importer = new \Espo\Core\Mail\Importer($this->getEntityManager(), $this->getFileManager(), $this->getConfig()); + $importer = new \Espo\Core\Mail\Importer($this->getEntityManager(), $this->getConfig()); $maxSize = $this->getConfig()->get('emailMessageMaxSize');