Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsovdef0bbd55e19
diff --git a/application/Espo/Classes/FieldProcessing/Email/AddressDataLoader.php b/application/Espo/Classes/FieldProcessing/Email/AddressDataLoader.php
index 8314a33dca..a940abfda8 100644
--- a/application/Espo/Classes/FieldProcessing/Email/AddressDataLoader.php
+++ b/application/Espo/Classes/FieldProcessing/Email/AddressDataLoader.php
@@ -52,11 +52,6 @@ class AddressDataLoader implements Loader
/** @var EmailRepository $repository */
$repository = $this->entityManager->getRepository(Email::ENTITY_TYPE);
- $repository->loadFromField($entity);
- $repository->loadToField($entity);
- $repository->loadCcField($entity);
- $repository->loadBccField($entity);
- $repository->loadReplyToField($entity);
$repository->loadNameHash($entity);
}
}
diff --git a/application/Espo/Classes/FieldProcessing/Email/AddressLoader.php b/application/Espo/Classes/FieldProcessing/Email/AddressLoader.php
new file mode 100644
index 0000000000..295e57e02c
--- /dev/null
+++ b/application/Espo/Classes/FieldProcessing/Email/AddressLoader.php
@@ -0,0 +1,60 @@
+<?php
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM – Open Source CRM application.
+ * Copyright (C) 2014-2025 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
+ * Website: https://www.espocrm.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU Affero General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
+ ************************************************************************/
+
+namespace Espo\Classes\FieldProcessing\Email;
+
+use Espo\Core\FieldProcessing\Loader;
+use Espo\Core\FieldProcessing\Loader\Params;
+use Espo\Core\ORM\EntityManager;
+use Espo\Entities\Email;
+use Espo\ORM\Entity;
+use Espo\Repositories\Email as EmailRepository;
+
+/**
+ * @implements Loader<Email>
+ */
+class AddressLoader implements Loader
+{
+ public function __construct(private EntityManager $entityManager)
+ {}
+ /**
+ * @inheritDoc
+ */
+ public function process(Entity $entity, Params $params): void
+ {
+ /** @var EmailRepository $repository */
+ $repository = $this->entityManager->getRepository(Email::ENTITY_TYPE);
+
+ $repository->loadFromField($entity);
+ $repository->loadToField($entity);
+ $repository->loadCcField($entity);
+ $repository->loadBccField($entity);
+ $repository->loadReplyToField($entity);
+ }
+}
diff --git a/application/Espo/Resources/metadata/entityDefs/Email.json b/application/Espo/Resources/metadata/entityDefs/Email.json
index e83f96efda..4542abb8c9 100644
--- a/application/Espo/Resources/metadata/entityDefs/Email.json
+++ b/application/Espo/Resources/metadata/entityDefs/Email.json
@@ -94,7 +94,7 @@
"filters"
],
"massUpdateDisabled": true,
- "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressDataLoader"
+ "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressLoader"
},
"to": {
"type": "varchar",
@@ -102,7 +102,7 @@
"orderDisabled": true,
"required": true,
"view": "views/email/fields/email-address-varchar",
- "validatorClassName": "Espo\\Classes\\FieldValidators\\Email\\EmailAddresses",
+ "validatorClassName": "Espo\\Classes\\FieldValidators\\Email\\AddressLoader",
"validatorClassNameList": [
"Espo\\Classes\\FieldValidators\\Email\\Addresses\\Valid",
"Espo\\Classes\\FieldValidators\\Email\\Addresses\\MaxCount"
@@ -114,7 +114,7 @@
"filters"
],
"massUpdateDisabled": true,
- "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressDataLoader"
+ "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressLoader"
},
"cc": {
"type": "varchar",
@@ -132,7 +132,7 @@
"filters"
],
"massUpdateDisabled": true,
- "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressDataLoader"
+ "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressLoader"
},
"bcc": {
"type": "varchar",
@@ -149,7 +149,7 @@
"detail"
],
"massUpdateDisabled": true,
- "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressDataLoader"
+ "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressLoader"
},
"replyTo": {
"type": "varchar",
@@ -162,7 +162,7 @@
"detail"
],
"massUpdateDisabled": true,
- "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressDataLoader"
+ "loaderClassName": "Espo\\Classes\\FieldProcessing\\Email\\AddressLoader"
},
"personStringData": {
"type": "varchar",
diff --git a/application/Espo/Resources/metadata/recordDefs/Email.json b/application/Espo/Resources/metadata/recordDefs/Email.json
index c10aee76a0..159a84a211 100644
--- a/application/Espo/Resources/metadata/recordDefs/Email.json
+++ b/application/Espo/Resources/metadata/recordDefs/Email.json
@@ -1,6 +1,7 @@
{
"loadAdditionalFieldsAfterUpdate": true,
"readLoaderClassNameList": [
+ "Espo\\Classes\\FieldProcessing\\Email\\AddressLoader",
"Espo\\Classes\\FieldProcessing\\Email\\AddressDataLoader",
"Espo\\Classes\\FieldProcessing\\Email\\UserColumnsLoader",
"Espo\\Classes\\FieldProcessing\\Email\\FolderDataLoader",