This commit is contained in:
Yuri Kuznetsov
2021-09-22 21:48:20 +03:00
parent c3c1398a2d
commit c0ca2174b6
2 changed files with 12 additions and 14 deletions
+6 -7
View File
@@ -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(
+6 -7
View File
@@ -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(