From c0ca2174b6ac84801ba0a89840862ba6fec2a378 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 22 Sep 2021 21:48:20 +0300 Subject: [PATCH] ref --- application/Espo/Jobs/CheckEmailAccounts.php | 13 ++++++------- application/Espo/Jobs/CheckInboundEmails.php | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/application/Espo/Jobs/CheckEmailAccounts.php b/application/Espo/Jobs/CheckEmailAccounts.php index 6063bdc75a..7bce4df6fd 100644 --- a/application/Espo/Jobs/CheckEmailAccounts.php +++ b/application/Espo/Jobs/CheckEmailAccounts.php @@ -31,10 +31,11 @@ namespace Espo\Jobs; use Espo\Core\Exceptions\Error; +use Espo\Services\EmailAccount as Service; + use Espo\Core\{ Job\Job, Job\Job\Data, - ServiceFactory, ORM\EntityManager, }; @@ -42,13 +43,13 @@ use Throwable; class CheckEmailAccounts implements Job { - private $serviceFactory; + private $service; private $entityManager; - public function __construct(ServiceFactory $serviceFactory, EntityManager $entityManager) + public function __construct(Service $service, EntityManager $entityManager) { - $this->serviceFactory = $serviceFactory; + $this->service = $service; $this->entityManager = $entityManager; } @@ -60,8 +61,6 @@ class CheckEmailAccounts implements Job throw new Error("No target."); } - $service = $this->serviceFactory->create('EmailAccount'); - $entity = $this->entityManager->getEntity('EmailAccount', $targetId); if (!$entity) { @@ -73,7 +72,7 @@ class CheckEmailAccounts implements Job } try { - $service->fetchFromMailServer($entity); + $this->service->fetchFromMailServer($entity); } catch (Throwable $e) { throw new Error( diff --git a/application/Espo/Jobs/CheckInboundEmails.php b/application/Espo/Jobs/CheckInboundEmails.php index 0965b3f68a..76dd30e2f5 100644 --- a/application/Espo/Jobs/CheckInboundEmails.php +++ b/application/Espo/Jobs/CheckInboundEmails.php @@ -31,10 +31,11 @@ namespace Espo\Jobs; use Espo\Core\Exceptions\Error; +use Espo\Services\InboundEmail as Service; + use Espo\Core\{ Job\Job, Job\Job\Data, - ServiceFactory, ORM\EntityManager, }; @@ -42,13 +43,13 @@ use Throwable; class CheckInboundEmails implements Job { - private $serviceFactory; + private $service; private $entityManager; - public function __construct(ServiceFactory $serviceFactory, EntityManager $entityManager) + public function __construct(Service $service, EntityManager $entityManager) { - $this->serviceFactory = $serviceFactory; + $this->service = $service; $this->entityManager = $entityManager; } @@ -60,8 +61,6 @@ class CheckInboundEmails implements Job throw new Error("No target."); } - $service = $this->serviceFactory->create('InboundEmail'); - $entity = $this->entityManager->getEntity('InboundEmail', $targetId); if (!$entity) { @@ -73,7 +72,7 @@ class CheckInboundEmails implements Job } try { - $service->fetchFromMailServer($entity); + $this->service->fetchFromMailServer($entity); } catch (Throwable $e) { throw new Error(