Skip to content

EspoCRM – Open Source CRM Application

ref

Yuri Kuznetsovc6c2d5a0d95c
diff --git a/application/Espo/Classes/Cleanup/WebhookQueue.php b/application/Espo/Classes/Cleanup/WebhookQueue.php
index e2793b1c91..62268d12f1 100644
--- a/application/Espo/Classes/Cleanup/WebhookQueue.php
+++ b/application/Espo/Classes/Cleanup/WebhookQueue.php
@@ -31,42 +31,40 @@ namespace Espo\Classes\Cleanup;
use Espo\Core\Cleanup\Cleanup;
use Espo\Core\Utils\Config;
+use Espo\Core\Utils\DateTime as DateTimeUtil;
+use Espo\Entities\WebhookEventQueueItem;
+use Espo\Entities\WebhookQueueItem;
use Espo\ORM\EntityManager;
-
use DateTime;
+use Espo\ORM\Name\Attribute;
+/**
+ * @noinspection PhpUnused
+ */
class WebhookQueue implements Cleanup
{
private string $cleanupWebhookQueuePeriod = '10 days';
- private $config;
-
- private $entityManager;
-
- public function __construct(Config $config, EntityManager $entityManager)
- {
- $this->config = $config;
- $this->entityManager = $entityManager;
- }
+ public function __construct(private Config $config, private EntityManager $entityManager)
+ {}
public function process(): void
{
$period = '-' . $this->config->get('cleanupWebhookQueuePeriod', $this->cleanupWebhookQueuePeriod);
$datetime = new DateTime();
-
$datetime->modify($period);
- $from = $datetime->format('Y-m-d H:i:s');
+ $from = $datetime->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
$query1 = $this->entityManager
->getQueryBuilder()
->delete()
- ->from('WebhookQueueItem')
+ ->from(WebhookQueueItem::ENTITY_TYPE)
->where([
'DATE:(createdAt)<' => $from,
'OR' => [
- 'status!=' => 'Pending',
- 'deleted' => true,
+ 'status!=' => WebhookQueueItem::STATUS_PENDING,
+ Attribute::DELETED => true,
],
])
->build();
@@ -76,12 +74,12 @@ class WebhookQueue implements Cleanup
$query2 = $this->entityManager
->getQueryBuilder()
->delete()
- ->from('WebhookEventQueueItem')
+ ->from(WebhookEventQueueItem::ENTITY_TYPE)
->where([
'DATE:(createdAt)<' => $from,
'OR' => [
'isProcessed' => true,
- 'deleted' => true,
+ Attribute::DELETED => true,
],
])
->build();
diff --git a/application/Espo/Classes/FieldConverters/RelationshipRole.php b/application/Espo/Classes/FieldConverters/RelationshipRole.php
index a566d84a7a..10446762ce 100644
--- a/application/Espo/Classes/FieldConverters/RelationshipRole.php
+++ b/application/Espo/Classes/FieldConverters/RelationshipRole.php
@@ -85,7 +85,7 @@ class RelationshipRole implements FieldConverter
'from' => $midTable,
'select' => [$nearKey],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
$column => '{value}',
],
],
@@ -97,7 +97,7 @@ class RelationshipRole implements FieldConverter
'from' => $midTable,
'select' => [$nearKey],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
$column => '{value}',
],
],
@@ -109,7 +109,7 @@ class RelationshipRole implements FieldConverter
'from' => $midTable,
'select' => [$nearKey],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
$column => '{value}',
],
],
@@ -121,7 +121,7 @@ class RelationshipRole implements FieldConverter
'from' => $midTable,
'select' => [$nearKey],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
$column => '{value}',
],
],
@@ -133,7 +133,7 @@ class RelationshipRole implements FieldConverter
'from' => $midTable,
'select' => [$nearKey],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
"$column*" => '{value}',
],
],
@@ -145,7 +145,7 @@ class RelationshipRole implements FieldConverter
'from' => $midTable,
'select' => [$nearKey],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
"$column*" => '{value}',
],
],
diff --git a/application/Espo/Classes/FieldProcessing/Email/UserColumnsLoader.php b/application/Espo/Classes/FieldProcessing/Email/UserColumnsLoader.php
index 3d5896ad01..43fe60e712 100644
--- a/application/Espo/Classes/FieldProcessing/Email/UserColumnsLoader.php
+++ b/application/Espo/Classes/FieldProcessing/Email/UserColumnsLoader.php
@@ -35,6 +35,7 @@ use Espo\Core\FieldProcessing\Loader;
use Espo\Core\FieldProcessing\Loader\Params;
use Espo\Core\ORM\EntityManager;
use Espo\Entities\User;
+use Espo\ORM\Name\Attribute;
/**
* @implements Loader<Email>
@@ -57,7 +58,7 @@ class UserColumnsLoader implements Loader
Email::USERS_COLUMN_IN_ARCHIVE,
])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $this->user->getId(),
'emailId' => $entity->getId(),
])
diff --git a/application/Espo/Classes/Jobs/Cleanup.php b/application/Espo/Classes/Jobs/Cleanup.php
index ac51e10ffa..843e4e3ce3 100644
--- a/application/Espo/Classes/Jobs/Cleanup.php
+++ b/application/Espo/Classes/Jobs/Cleanup.php
@@ -149,7 +149,7 @@ class Cleanup implements JobDataLess
->where([
'modifiedAt<' => $this->getCleanupJobFromDate(),
'status=' => JobStatus::PENDING,
- 'deleted' => true,
+ Attribute::DELETED => true,
])
->build();
@@ -412,7 +412,7 @@ class Cleanup implements JobDataLess
->from($scope)
->withDeleted()
->where([
- 'deleted' => true,
+ Attribute::DELETED => true,
'modifiedAt<' => $datetime->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
'modifiedAt>' => $datetimeFrom->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
])
@@ -465,7 +465,7 @@ class Cleanup implements JobDataLess
->delete()
->from(Attachment::ENTITY_TYPE)
->where([
- 'deleted' => true,
+ Attribute::DELETED => true,
'createdAt<' => $datetime->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
])
->build();
@@ -492,7 +492,7 @@ class Cleanup implements JobDataLess
->select([Attribute::ID])
->where([
'createdAt<' => $dateBefore,
- 'deleted' => true,
+ Attribute::DELETED => true,
])
->find();
@@ -516,8 +516,8 @@ class Cleanup implements JobDataLess
->delete()
->from(Email::ENTITY_TYPE)
->where([
- 'deleted' => true,
- 'id' => $id,
+ Attribute::DELETED => true,
+ Attribute::ID => $id,
])
->build();
@@ -584,7 +584,7 @@ class Cleanup implements JobDataLess
{
$scope = $entity->getEntityType();
- if (!$entity->get('deleted')) {
+ if (!$entity->get(Attribute::DELETED)) {
return;
}
@@ -675,7 +675,7 @@ class Cleanup implements JobDataLess
foreach ($noteList as $note) {
$this->entityManager->removeEntity($note);
- $note->set('deleted', true);
+ $note->set(Attribute::DELETED, true);
$this->cleanupDeletedEntity($note);
}
@@ -759,13 +759,13 @@ class Cleanup implements JobDataLess
$service = $this->recordServiceContainer->get($scope);
- $whereClause = ['deleted' => true];
+ $whereClause = [Attribute::DELETED => true];
if (
!$this->entityManager
->getDefs()
->getEntity($scope)
- ->hasAttribute('deleted')
+ ->hasAttribute(Attribute::DELETED)
) {
continue;
}
diff --git a/application/Espo/Classes/Select/EmailAddress/PrimaryFilters/Orphan.php b/application/Espo/Classes/Select/EmailAddress/PrimaryFilters/Orphan.php
index dac953e7b2..0f2f98f929 100644
--- a/application/Espo/Classes/Select/EmailAddress/PrimaryFilters/Orphan.php
+++ b/application/Espo/Classes/Select/EmailAddress/PrimaryFilters/Orphan.php
@@ -30,6 +30,7 @@
namespace Espo\Classes\Select\EmailAddress\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Query\SelectBuilder;
class Orphan implements Filter
@@ -42,24 +43,24 @@ class Orphan implements Filter
'EntityEmailAddress',
'entityEmailAddress',
[
- 'emailAddressId:' => 'id',
- 'deleted' => false,
+ 'emailAddressId:' => Attribute::ID,
+ Attribute::DELETED => false,
]
)
->leftJoin(
'EmailEmailAddress',
'emailEmailAddress',
[
- 'emailAddressId:' => 'id',
- 'deleted' => false,
+ 'emailAddressId:' => Attribute::ID,
+ Attribute::DELETED => false,
]
)
->leftJoin(
'Email',
'email',
[
- 'fromEmailAddressId:' => 'id',
- 'deleted' => false,
+ 'fromEmailAddressId:' => Attribute::ID,
+ Attribute::DELETED => false,
]
)
->where([
diff --git a/application/Espo/Classes/Select/PhoneNumber/PrimaryFilters/Orphan.php b/application/Espo/Classes/Select/PhoneNumber/PrimaryFilters/Orphan.php
index c68d89ccfc..1fa3a009bf 100644
--- a/application/Espo/Classes/Select/PhoneNumber/PrimaryFilters/Orphan.php
+++ b/application/Espo/Classes/Select/PhoneNumber/PrimaryFilters/Orphan.php
@@ -30,6 +30,7 @@
namespace Espo\Classes\Select\PhoneNumber\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Query\SelectBuilder;
class Orphan implements Filter
@@ -44,8 +45,8 @@ class Orphan implements Filter
'EntityPhoneNumber',
'entityPhoneNumber',
[
- 'phoneNumberId:' => 'id',
- 'deleted' => false,
+ 'phoneNumberId:' => Attribute::ID,
+ Attribute::DELETED => false,
]
);
diff --git a/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php b/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php
index 4962479917..ab53000765 100644
--- a/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php
+++ b/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php
@@ -32,6 +32,7 @@ namespace Espo\Core\FieldProcessing\EmailAddress;
use Espo\Core\ORM\Repository\Option\SaveOption;
use Espo\Core\ORM\Type\FieldType;
use Espo\Entities\EmailAddress;
+use Espo\ORM\Name\Attribute;
use Espo\Repositories\EmailAddress as EmailAddressRepository;
use Espo\ORM\Entity;
use Espo\Core\ApplicationState;
@@ -332,14 +333,14 @@ class Saver implements SaverInterface
'entityType' => $entity->getEntityType(),
'emailAddressId' => $emailAddress->getId(),
'primary' => $address === $primary,
- 'deleted' => false,
+ Attribute::DELETED => false,
]);
$mapper = $this->entityManager->getMapper();
$mapper->insertOnDuplicateUpdate($entityEmailAddress, [
'primary',
- 'deleted',
+ Attribute::DELETED,
]);
}
@@ -358,7 +359,7 @@ class Saver implements SaverInterface
'entityId' => $entity->getId(),
'entityType' => $entity->getEntityType(),
'primary' => true,
- 'deleted' => false,
+ Attribute::DELETED => false,
])
->build();
@@ -373,7 +374,7 @@ class Saver implements SaverInterface
'entityId' => $entity->getId(),
'entityType' => $entity->getEntityType(),
'emailAddressId' => $emailAddress->getId(),
- 'deleted' => false,
+ Attribute::DELETED => false,
])
->build();
diff --git a/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php b/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php
index 77ba0c0969..50105945c1 100644
--- a/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php
+++ b/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php
@@ -32,6 +32,7 @@ namespace Espo\Core\FieldProcessing\PhoneNumber;
use Espo\Core\ORM\Repository\Option\SaveOption;
use Espo\Core\ORM\Type\FieldType;
use Espo\Entities\PhoneNumber;
+use Espo\ORM\Name\Attribute;
use Espo\Repositories\PhoneNumber as PhoneNumberRepository;
use Espo\ORM\Entity;
use Espo\ORM\EntityManager;
@@ -337,7 +338,7 @@ class Saver implements SaverInterface
'entityType' => $entity->getEntityType(),
'phoneNumberId' => $phoneNumber->getId(),
'primary' => $number === $primary,
- 'deleted' => false,
+ Attribute::DELETED => false,
]);
/** @var BaseMapper $mapper */
@@ -345,7 +346,7 @@ class Saver implements SaverInterface
$mapper->insertOnDuplicateUpdate($entityPhoneNumber, [
'primary',
- 'deleted',
+ Attribute::DELETED,
]);
}
@@ -364,7 +365,7 @@ class Saver implements SaverInterface
'entityId' => $entity->getId(),
'entityType' => $entity->getEntityType(),
'primary' => true,
- 'deleted' => false,
+ Attribute::DELETED => false,
])
->build();
@@ -379,7 +380,7 @@ class Saver implements SaverInterface
'entityId' => $entity->getId(),
'entityType' => $entity->getEntityType(),
'phoneNumberId' => $phoneNumber->getId(),
- 'deleted' => false,
+ Attribute::DELETED => false,
])
->build();
diff --git a/application/Espo/Core/Formula/Functions/EntityGroup/SumRelatedType.php b/application/Espo/Core/Formula/Functions/EntityGroup/SumRelatedType.php
index 0f8b5ab62d..aadb5a9521 100644
--- a/application/Espo/Core/Formula/Functions/EntityGroup/SumRelatedType.php
+++ b/application/Espo/Core/Formula/Functions/EntityGroup/SumRelatedType.php
@@ -113,7 +113,7 @@ class SumRelatedType extends \Espo\Core\Formula\Functions\Base implements
$foreignLinkAlias,
[
$foreignLinkAlias . '.id:' => $foreignLink . 'Id',
- 'deleted' => false,
+ Attribute::DELETED => false,
$foreignLinkAlias . '.id!=' => null,
]
)
diff --git a/application/Espo/Core/Record/Service.php b/application/Espo/Core/Record/Service.php
index eaa94c85f8..428956acaf 100644
--- a/application/Espo/Core/Record/Service.php
+++ b/application/Espo/Core/Record/Service.php
@@ -907,7 +907,7 @@ class Service implements Crud,
throw new NotFound();
}
- if (!$entity->get('deleted')) {
+ if (!$entity->get(Attribute::DELETED)) {
throw new Forbidden("No 'deleted' attribute.");
}
diff --git a/application/Espo/Core/Select/Where/ItemGeneralConverter.php b/application/Espo/Core/Select/Where/ItemGeneralConverter.php
index 082974f514..eac45bdfff 100644
--- a/application/Espo/Core/Select/Where/ItemGeneralConverter.php
+++ b/application/Espo/Core/Select/Where/ItemGeneralConverter.php
@@ -622,7 +622,7 @@ class ItemGeneralConverter implements ItemConverter
'value' => $arrayValue,
'attribute' => $arrayAttribute,
'entityType' => $arrayEntityType,
- 'deleted' => false,
+ Attribute::DELETED => false,
])
->build()
];
diff --git a/application/Espo/Core/Upgrades/Migrations/V7_5/Prepare.php b/application/Espo/Core/Upgrades/Migrations/V7_5/Prepare.php
index 93bead6d82..5bdf80c789 100644
--- a/application/Espo/Core/Upgrades/Migrations/V7_5/Prepare.php
+++ b/application/Espo/Core/Upgrades/Migrations/V7_5/Prepare.php
@@ -32,6 +32,7 @@ namespace Espo\Core\Upgrades\Migrations\V7_5;
use Espo\Core\Upgrades\Migration\Script;
use Espo\Entities\User;
use Espo\ORM\EntityManager;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Query\DeleteBuilder;
class Prepare implements Script
@@ -44,7 +45,7 @@ class Prepare implements Script
{
$query = DeleteBuilder::create()
->from(User::ENTITY_TYPE)
- ->where(['deleted' => true])
+ ->where([Attribute::DELETED => true])
->build();
$this->entityManager->getQueryExecutor()->execute($query);
diff --git a/application/Espo/Core/Utils/Database/Orm/FieldConverters/Email.php b/application/Espo/Core/Utils/Database/Orm/FieldConverters/Email.php
index 3539b05980..6eefd8e63e 100644
--- a/application/Espo/Core/Utils/Database/Orm/FieldConverters/Email.php
+++ b/application/Espo/Core/Utils/Database/Orm/FieldConverters/Email.php
@@ -37,6 +37,7 @@ use Espo\Core\Utils\Database\Orm\Defs\RelationDefs;
use Espo\Core\Utils\Database\Orm\FieldConverter;
use Espo\Entities\EmailAddress;
use Espo\ORM\Defs\FieldDefs;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Type\AttributeType;
use Espo\ORM\Type\RelationType;
@@ -166,7 +167,7 @@ class Email implements FieldConverter
]
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
"LIKE:(emailAddress.lower, LOWER:({value})):" => null,
],
@@ -189,7 +190,7 @@ class Email implements FieldConverter
]
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
"LIKE:(emailAddress.lower, LOWER:({value})):" => null,
],
@@ -218,7 +219,7 @@ class Email implements FieldConverter
]
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
"EQUAL:(emailAddress.lower, LOWER:({value})):" => null,
],
@@ -241,7 +242,7 @@ class Email implements FieldConverter
]
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
"emailAddress.lower" => '{value}',
],
@@ -264,7 +265,7 @@ class Email implements FieldConverter
]
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
"emailAddress.lower" => '{value}',
],
@@ -283,7 +284,7 @@ class Email implements FieldConverter
'from' => 'EntityEmailAddress',
'select' => ['entityId'],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
],
],
diff --git a/application/Espo/Core/Utils/Database/Orm/FieldConverters/Phone.php b/application/Espo/Core/Utils/Database/Orm/FieldConverters/Phone.php
index 08c78f0df8..2292bf33ba 100644
--- a/application/Espo/Core/Utils/Database/Orm/FieldConverters/Phone.php
+++ b/application/Espo/Core/Utils/Database/Orm/FieldConverters/Phone.php
@@ -37,6 +37,7 @@ use Espo\Core\Utils\Database\Orm\Defs\RelationDefs;
use Espo\Core\Utils\Database\Orm\FieldConverter;
use Espo\Entities\PhoneNumber;
use Espo\ORM\Defs\FieldDefs;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Type\AttributeType;
use Espo\ORM\Type\RelationType;
@@ -178,7 +179,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.name*' => '{value}',
],
@@ -201,7 +202,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.name*' => '{value}',
],
@@ -230,7 +231,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.name' => '{value}',
],
@@ -253,7 +254,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.name' => '{value}',
],
@@ -276,7 +277,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.name!=' => '{value}',
],
@@ -295,7 +296,7 @@ class Phone implements FieldConverter
'from' => 'EntityPhoneNumber',
'select' => ['entityId'],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
],
],
@@ -456,7 +457,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.numeric*' => '{value}',
],
@@ -479,7 +480,7 @@ class Phone implements FieldConverter
]
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.numeric*' => '{value}',
],
@@ -502,7 +503,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.numeric' => '{value}',
],
@@ -525,7 +526,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.numeric' => '{value}',
],
@@ -548,7 +549,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.numeric' => '{value}',
],
@@ -571,7 +572,7 @@ class Phone implements FieldConverter
],
],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
'phoneNumber.numeric' => '{value}',
],
@@ -590,7 +591,7 @@ class Phone implements FieldConverter
'from' => 'EntityPhoneNumber',
'select' => ['entityId'],
'whereClause' => [
- 'deleted' => false,
+ Attribute::DELETED => false,
'entityType' => $entityType,
],
],
diff --git a/application/Espo/Hooks/Common/DeleteId.php b/application/Espo/Hooks/Common/DeleteId.php
index cc9966be1a..42b61c4c53 100644
--- a/application/Espo/Hooks/Common/DeleteId.php
+++ b/application/Espo/Hooks/Common/DeleteId.php
@@ -33,6 +33,7 @@ use Espo\Core\Hook\Hook\BeforeRemove;
use Espo\Core\Utils\Metadata;
use Espo\Core\Utils\Util;
use Espo\ORM\Entity;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Repository\Option\RemoveOptions;
use Espo\ORM\Repository\Option\SaveOptions;
use Espo\Core\Hook\Hook\BeforeSave;
@@ -46,7 +47,7 @@ use Espo\Core\Hook\Hook\BeforeSave;
class DeleteId implements BeforeSave, BeforeRemove
{
private const ID_ATTR = 'deleteId';
- private const DELETED_ATTR = 'deleted';
+ private const DELETED_ATTR = Attribute::DELETED;
public function __construct(
private Metadata $metadata,
diff --git a/application/Espo/Modules/Crm/Hooks/Contact/Accounts.php b/application/Espo/Modules/Crm/Hooks/Contact/Accounts.php
index 0d86d3bfe9..bce67a6579 100644
--- a/application/Espo/Modules/Crm/Hooks/Contact/Accounts.php
+++ b/application/Espo/Modules/Crm/Hooks/Contact/Accounts.php
@@ -33,6 +33,7 @@ use Espo\Core\Hook\Hook\AfterSave;
use Espo\Modules\Crm\Entities\Contact;
use Espo\ORM\Entity;
use Espo\ORM\EntityManager;
+use Espo\ORM\Name\Attribute;
use Espo\ORM\Repository\Option\SaveOptions;
/**
@@ -79,7 +80,7 @@ class Accounts implements AfterSave
->where([
'accountId' => $accountId,
'contactId' => $entity->getId(),
- 'deleted' => false,
+ Attribute::DELETED => false,
])
->findOne();
diff --git a/application/Espo/Modules/Crm/Tools/TargetList/RecordService.php b/application/Espo/Modules/Crm/Tools/TargetList/RecordService.php
index 45ff8b5409..a84dcc99b9 100644
--- a/application/Espo/Modules/Crm/Tools/TargetList/RecordService.php
+++ b/application/Espo/Modules/Crm/Tools/TargetList/RecordService.php
@@ -38,6 +38,7 @@ use Espo\Core\HookManager;
use Espo\Modules\Crm\Entities\TargetList;
use Espo\ORM\Defs\Params\RelationParam;
use Espo\ORM\EntityManager;
+use Espo\ORM\Name\Attribute;
use RuntimeException;
class RecordService
@@ -65,7 +66,7 @@ class RecordService
$updateQuery = $this->entityManager->getQueryBuilder()
->update()
->in($linkEntityType)
- ->set(['deleted' => true])
+ ->set([Attribute::DELETED => true])
->where(['targetListId' => $entity->getId()])
->build();
diff --git a/application/Espo/Repositories/User.php b/application/Espo/Repositories/User.php
index 0f0b8463a8..591cea6007 100644
--- a/application/Espo/Repositories/User.php
+++ b/application/Espo/Repositories/User.php
@@ -29,8 +29,10 @@
namespace Espo\Repositories;
+use Espo\Entities\Team;
use Espo\ORM\Entity;
use Espo\Core\Repositories\Database;
+use Espo\ORM\Name\Attribute;
use Espo\Repositories\UserData as UserDataRepository;
use Espo\Entities\UserData;
use Espo\Entities\User as UserEntity;
@@ -124,9 +126,9 @@ class User extends Database
}
return (bool) $this->entityManager
- ->getRDBRepository('TeamUser')
+ ->getRDBRepository(Team::RELATIONSHIP_TEAM_USER)
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'teamId' => $teamIds,
])
diff --git a/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php b/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php
index e07b869f8b..d6bf4a0a1e 100644
--- a/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php
+++ b/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php
@@ -65,7 +65,7 @@ class CheckNewExtensionVersion implements JobDataLess
->from(Extension::ENTITY_TYPE)
->select([Attribute::ID, Field::NAME, 'version', 'checkVersionUrl'])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'isInstalled' => true,
])
->order([Field::CREATED_AT])
diff --git a/application/Espo/Tools/Email/InboxService.php b/application/Espo/Tools/Email/InboxService.php
index 165d2ff667..2695e48431 100644
--- a/application/Espo/Tools/Email/InboxService.php
+++ b/application/Espo/Tools/Email/InboxService.php
@@ -140,7 +140,7 @@ class InboxService
'inArchive' => false,
])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -245,7 +245,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['inTrash' => true])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -297,7 +297,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['inTrash' => false])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -336,7 +336,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['isRead' => true])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -357,7 +357,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['isRead' => false])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -396,7 +396,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['isImportant' => true])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -415,7 +415,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['isImportant' => false])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'emailId' => $id,
])
@@ -434,7 +434,7 @@ class InboxService
->in(Email::RELATIONSHIP_EMAIL_USER)
->set(['isRead' => true])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'isRead' => false,
])
@@ -449,7 +449,7 @@ class InboxService
->in(Notification::ENTITY_TYPE)
->set(['read' => true])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $userId,
'relatedType' => Email::ENTITY_TYPE,
'read' => false,
@@ -604,7 +604,7 @@ class InboxService
'inTrash' => false,
])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $user->getId(),
'emailId' => $email->getId(),
])
@@ -624,7 +624,7 @@ class InboxService
'inArchive' => false,
])
->where([
- 'deleted' => false,
+ Attribute::DELETED => false,
'userId' => $user->getId(),
'emailId' => $email->getId(),
])
diff --git a/application/Espo/Tools/EntityManager/NameUtil.php b/application/Espo/Tools/EntityManager/NameUtil.php
index ba740489de..61f1c53ee8 100644
--- a/application/Espo/Tools/EntityManager/NameUtil.php
+++ b/application/Espo/Tools/EntityManager/NameUtil.php
@@ -38,6 +38,7 @@ use Espo\Core\ServiceFactory;
use Espo\ORM\Defs\Params\EntityParam;
use Espo\ORM\EntityManager;
use Espo\ORM\Entity;
+use Espo\ORM\Name\Attribute;
class NameUtil
{
@@ -134,8 +135,8 @@ class NameUtil
* @var string[]
*/
public const FIELD_FORBIDDEN_NAME_LIST = [
- 'id',
- 'deleted',
+ Attribute::ID,
+ Attribute::DELETED,
'deleteId',
'skipDuplicateCheck',
'versionNumber',
diff --git a/application/Espo/Tools/Export/Export.php b/application/Espo/Tools/Export/Export.php
index cfe241048b..adbbc44c5d 100644
--- a/application/Espo/Tools/Export/Export.php
+++ b/application/Espo/Tools/Export/Export.php
@@ -33,6 +33,7 @@ use Espo\Core\ORM\Defs\AttributeParam;
use Espo\Core\ORM\Repository\Option\SaveOption;
use Espo\Core\Record\Select\ApplierClassNameListProvider;
use Espo\ORM\Defs\Params\AttributeParam as OrmAttributeParam;
+use Espo\ORM\Name\Attribute;
use Espo\Tools\Export\Collection as ExportCollection;
use Espo\Tools\Export\Processor\Params as ProcessorParams;
use Espo\ORM\Entity;
@@ -334,7 +335,7 @@ class Export
GlobalRestriction::TYPE_INTERNAL,
]);
- $attributeListToSkip[] = 'deleted';
+ $attributeListToSkip[] = Attribute::DELETED;
$initialAttributeList = $params->getAttributeList();