diff --git a/application/Espo/Classes/AppParams/TemplateEntityTypeList.php b/application/Espo/Classes/AppParams/TemplateEntityTypeList.php index 666466b8a6..4e0d0fae95 100644 --- a/application/Espo/Classes/AppParams/TemplateEntityTypeList.php +++ b/application/Espo/Classes/AppParams/TemplateEntityTypeList.php @@ -40,8 +40,19 @@ use Espo\Core\{ */ class TemplateEntityTypeList { + /** + * @var Acl + */ protected $acl; + + /** + * @var SelectBuilderFactory + */ protected $selectBuilderFactory; + + /** + * @var EntityManager + */ protected $entityManager; public function __construct(Acl $acl, SelectBuilderFactory $selectBuilderFactory, EntityManager $entityManager) @@ -51,7 +62,7 @@ class TemplateEntityTypeList $this->entityManager = $entityManager; } - public function get() : array + public function get(): array { if (!$this->acl->checkScope('Template')) { return []; @@ -69,7 +80,7 @@ class TemplateEntityTypeList ->build(); $templateCollection = $this->entityManager - ->getRepository('Template') + ->getRDBRepository('Template') ->clone($query) ->find(); diff --git a/application/Espo/Classes/Jobs/CheckNewVersion.php b/application/Espo/Classes/Jobs/CheckNewVersion.php index dedc98049e..6bb970e6e0 100644 --- a/application/Espo/Classes/Jobs/CheckNewVersion.php +++ b/application/Espo/Classes/Jobs/CheckNewVersion.php @@ -40,8 +40,14 @@ use DateTimeZone; class CheckNewVersion implements JobDataLess { + /** + * @var Config + */ protected $config; + /** + * @var EntityManager + */ protected $entityManager; public function __construct(Config $config, EntityManager $entityManager) diff --git a/application/Espo/Classes/Select/Email/Where/ItemConverters/FromEquals.php b/application/Espo/Classes/Select/Email/Where/ItemConverters/FromEquals.php index 9448339efc..ee0470a49c 100644 --- a/application/Espo/Classes/Select/Email/Where/ItemConverters/FromEquals.php +++ b/application/Espo/Classes/Select/Email/Where/ItemConverters/FromEquals.php @@ -44,12 +44,16 @@ use Espo\{ class FromEquals implements ItemConverter { + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var EmailAddressHelper + */ protected $emailAddressHelper; - protected $randomStringGenerator; - public function __construct( EntityManager $entityManager, EmailAddressHelper $emailAddressHelper diff --git a/application/Espo/Classes/Select/Email/Where/ItemConverters/InFolder.php b/application/Espo/Classes/Select/Email/Where/ItemConverters/InFolder.php index 57f2bd4e9a..28f136a938 100644 --- a/application/Espo/Classes/Select/Email/Where/ItemConverters/InFolder.php +++ b/application/Espo/Classes/Select/Email/Where/ItemConverters/InFolder.php @@ -45,10 +45,19 @@ use Espo\{ class InFolder implements ItemConverter { + /** + * @var User + */ protected $user; + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var JoinHelper + */ protected $joinHelper; public function __construct(User $user, EntityManager $entityManager, JoinHelper $joinHelper) @@ -186,7 +195,7 @@ class InFolder implements ItemConverter protected function getEmailAddressIdList(): array { $emailAddressList = $this->entityManager - ->getRepository('User') + ->getRDBRepository('User') ->getRelation($this->user, 'emailAddresses') ->select(['id']) ->find(); @@ -194,7 +203,7 @@ class InFolder implements ItemConverter $emailAddressIdList = []; foreach ($emailAddressList as $emailAddress) { - $emailAddressIdList[] = $emailAddress->id; + $emailAddressIdList[] = $emailAddress->getId(); } return $emailAddressIdList; diff --git a/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php b/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php index bc89c2b004..6460902eb7 100644 --- a/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php +++ b/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php @@ -45,8 +45,14 @@ class CampaignTrackOpened implements EntryPoint { use NoAuth; + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var Service + */ protected $service; public function __construct(EntityManager $entityManager, Service $service) diff --git a/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php b/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php index 2cea5c0f52..a442e78c6c 100644 --- a/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php +++ b/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php @@ -30,6 +30,7 @@ namespace Espo\Modules\Crm\EntryPoints; use Espo\Modules\Crm\Services\Campaign as Service; +use Espo\Repositories\EmailAddress as EmailAddressRepository; use Espo\{ Modules\Crm\Entities\EmailQueueItem, @@ -54,16 +55,34 @@ class CampaignUrl implements EntryPoint { use NoAuth; + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var Service + */ protected $service; + /** + * @var Hasher + */ protected $hasher; + /** + * @var HookManager + */ protected $hookManager; + /** + * @var ClientManager + */ protected $clientManager; + /** + * @var Metadata + */ protected $metadata; public function __construct( @@ -180,7 +199,7 @@ class CampaignUrl implements EntryPoint throw new NotFoundSilent(); } - $eaRepository = $this->entityManager->getRepository('EmailAddress'); + $eaRepository = $this->getEmailAddressRepository(); $ea = $eaRepository->getByAddress($emailAddress); @@ -229,4 +248,10 @@ class CampaignUrl implements EntryPoint $this->clientManager->display($runScript); } + + private function getEmailAddressRepository(): EmailAddressRepository + { + /** @var EmailAddressRepository */ + return $this->entityManager->getRepository('EmailAddress'); + } } diff --git a/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php b/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php index e75894f3d0..0216fcbeb3 100644 --- a/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php +++ b/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php @@ -46,10 +46,19 @@ class EventConfirmation implements EntryPoint { use NoAuth; + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var ClientManager + */ protected $clientManager; + /** + * @var HookManager + */ protected $hookManager; public function __construct(EntityManager $entityManager, ClientManager $clientManager, HookManager $hookManager) { @@ -71,7 +80,10 @@ class EventConfirmation implements EntryPoint throw new BadRequest(); } - $uniqueId = $this->entityManager->getRepository('UniqueId')->where(['name' => $uid])->findOne(); + $uniqueId = $this->entityManager + ->getRDBRepository('UniqueId') + ->where(['name' => $uid]) + ->findOne(); if (!$uniqueId) { throw new NotFound(); @@ -111,18 +123,21 @@ class EventConfirmation implements EntryPoint $data = (object) [ 'status' => $status ]; - $this->entityManager->getRepository($eventType)->updateRelation($event, $link, $invitee->id, $data); + + $this->entityManager + ->getRDBRepository($eventType) + ->updateRelation($event, $link, $invitee->getId(), $data); $actionData = [ 'eventName' => $event->get('name'), 'eventType' => $event->getEntityType(), - 'eventId' => $event->id, + 'eventId' => $event->getId(), 'dateStart' => $event->get('dateStart'), 'action' => $action, 'status' => $status, 'link' => $link, 'inviteeType' => $invitee->getEntityType(), - 'inviteeId' => $invitee->id + 'inviteeId' => $invitee->getId(), ]; $this->hookManager->process($event->getEntityType(), $hookMethodName, $event, [], $actionData); diff --git a/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php b/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php index 6121ad8b1e..d837609a33 100644 --- a/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php +++ b/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php @@ -29,6 +29,8 @@ namespace Espo\Modules\Crm\EntryPoints; +use Espo\Repositories\EmailAddress as EmailAddressRepository; + use Espo\Core\{ Exceptions\NotFound, Exceptions\BadRequest, @@ -48,16 +50,34 @@ class SubscribeAgain implements EntryPoint { use NoAuth; + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var ClientManager + */ protected $clientManager; + /** + * @var HookManager + */ protected $hookManager; + /** + * @var Config + */ protected $config; + /** + * @var Metadata + */ protected $metadata; + /** + * @var Hasher + */ protected $hasher; public function __construct( @@ -131,7 +151,7 @@ class SubscribeAgain implements EntryPoint $emailAddress = $target->get('emailAddress'); if ($emailAddress) { - $ea = $this->entityManager->getRepository('EmailAddress')->getByAddress($emailAddress); + $ea = $this->getEmailAddressRepository()->getByAddress($emailAddress); if ($ea) { $ea->set('optOut', false); @@ -155,14 +175,14 @@ class SubscribeAgain implements EntryPoint if ($link) { $targetListList = $this->entityManager - ->getRepository('MassEmail') + ->getRDBRepository('MassEmail') ->getRelation($massEmail, 'targetLists') ->find(); foreach ($targetListList as $targetList) { $optedInResult = $this->entityManager - ->getRepository('TargetList') - ->updateRelation($targetList, $link, $target->id, ['optedOut' => false]); + ->getRDBRepository('TargetList') + ->updateRelation($targetList, $link, $target->getId(), ['optedOut' => false]); if ($optedInResult) { $hookData = [ @@ -171,7 +191,8 @@ class SubscribeAgain implements EntryPoint 'targetType' => $targetType, ]; - $this->hookManager->process('TargetList', 'afterCancelOptOut', $targetList, [], $hookData); + $this->hookManager + ->process('TargetList', 'afterCancelOptOut', $targetList, [], $hookData); } } @@ -185,7 +206,7 @@ class SubscribeAgain implements EntryPoint if ($campaign && $target) { $logRecord = $this->entityManager - ->getRepository('CampaignLogRecord')->where([ + ->getRDBRepository('CampaignLogRecord')->where([ 'queueItemId' => $queueItemId, 'action' => 'Opted Out', ]) @@ -225,11 +246,12 @@ class SubscribeAgain implements EntryPoint throw new NotFound(); } - $repository = $this->entityManager->getRepository('EmailAddress'); + $repository = $this->getEmailAddressRepository(); $ea = $repository->getByAddress($emailAddress); + if ($ea) { - $entityList = $repository->getEntityListByAddressId($ea->id); + $entityList = $repository->getEntityListByAddressId($ea->getId()); if ($ea->get('optOut')) { $ea->set('optOut', false); @@ -250,4 +272,10 @@ class SubscribeAgain implements EntryPoint throw new NotFound(); } } + + private function getEmailAddressRepository(): EmailAddressRepository + { + /** @var EmailAddressRepository */ + return $this->entityManager->getRepository('EmailAddress'); + } } diff --git a/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php b/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php index 05853673ec..70f8d0359a 100644 --- a/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php +++ b/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php @@ -30,6 +30,7 @@ namespace Espo\Modules\Crm\EntryPoints; use Espo\Modules\Crm\Services\Campaign as Service; +use Espo\Repositories\EmailAddress as EmailAddressRepository; use Espo\Core\{ Exceptions\NotFound, @@ -50,18 +51,39 @@ class Unsubscribe implements EntryPoint { use NoAuth; + /** + * @var EntityManager + */ protected $entityManager; + /** + * @var ClientManager + */ protected $clientManager; + /** + * @var HookManager + */ protected $hookManager; + /** + * @var Config + */ protected $config; + /** + * @var Metadata + */ protected $metadata; + /** + * @var Hasher + */ protected $hasher; + /** + * @var Service + */ protected $service; public function __construct( @@ -137,7 +159,7 @@ class Unsubscribe implements EntryPoint $emailAddress = $target->get('emailAddress'); if ($emailAddress) { - $ea = $this->entityManager->getRepository('EmailAddress')->getByAddress($emailAddress); + $ea = $this->getEmailAddressRepository()->getByAddress($emailAddress); if ($ea) { $ea->set('optOut', true); @@ -161,14 +183,14 @@ class Unsubscribe implements EntryPoint if ($link) { $targetListList = $this->entityManager - ->getRepository('MassEmail') + ->getRDBRepository('MassEmail') ->getRelation($massEmail, 'targetLists') ->find(); foreach ($targetListList as $targetList) { $optedOutResult = $this->entityManager - ->getRepository('TargetList') - ->updateRelation($targetList, $link, $target->id, ['optedOut' => true]); + ->getRDBRepository('TargetList') + ->updateRelation($targetList, $link, $target->getId(), ['optedOut' => true]); if ($optedOutResult) { $hookData = [ @@ -228,7 +250,7 @@ class Unsubscribe implements EntryPoint throw new NotFound(); } - $repository = $this->entityManager->getRepository('EmailAddress'); + $repository = $this->getEmailAddressRepository(); $ea = $repository->getByAddress($emailAddress); @@ -253,4 +275,10 @@ class Unsubscribe implements EntryPoint throw new NotFound(); } } + + private function getEmailAddressRepository(): EmailAddressRepository + { + /** @var EmailAddressRepository */ + return $this->entityManager->getRepository('EmailAddress'); + } } diff --git a/application/Espo/Repositories/Preferences.php b/application/Espo/Repositories/Preferences.php index 33338842c6..c67df39263 100644 --- a/application/Espo/Repositories/Preferences.php +++ b/application/Espo/Repositories/Preferences.php @@ -55,6 +55,9 @@ class Preferences implements Repository, use Di\ConfigSetter; use Di\EntityManagerSetter; + /** + * @var EntityFactory + */ protected $entityFactory; public function __construct( @@ -76,6 +79,7 @@ class Preferences implements Repository, public function getNew(): Entity { + /** @var PreferencesEntity */ return $this->entityFactory->create('Preferences'); }