From 9e396b43a86747909d46322d4b7ebbeab204aec1 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 11 Nov 2024 16:04:47 +0200 Subject: [PATCH] const usage --- .../Espo/Classes/Acl/Email/AccessChecker.php | 6 +++--- .../Espo/Classes/Acl/Note/AccessChecker.php | 4 ++-- .../Classes/AclPortal/Note/AccessChecker.php | 5 +++-- .../Espo/Classes/Cleanup/Subscribers.php | 3 ++- .../ConsoleCommands/PopulateNumbers.php | 3 ++- .../DefaultLayouts/DefaultSidePanelType.php | 4 ++-- .../FieldProcessing/User/LastAccessLoader.php | 5 +++-- application/Espo/Classes/Jobs/Cleanup.php | 9 +++++---- .../Espo/Classes/Jobs/SendScheduledEmails.php | 3 ++- application/Espo/Controllers/Notification.php | 3 ++- application/Espo/Controllers/Stream.php | 3 ++- .../Authentication/AuthToken/EspoManager.php | 5 +++-- .../Authentication/TwoFactor/Email/Util.php | 3 ++- .../Core/Authentication/TwoFactor/Sms/Util.php | 3 ++- .../Core/FieldProcessing/Reminder/Saver.php | 10 +++++++--- .../Account/GroupAccount/Hooks/AfterFetch.php | 4 ++-- .../Core/Mail/Importer/DefaultImporter.php | 2 +- .../DefaultAssignmentNotificator.php | 3 ++- .../Espo/Core/Select/Bool/Filters/OnlyMy.php | 3 ++- .../Select/Helpers/RelationQueryHelper.php | 2 +- .../Orm/FieldConverters/AttachmentMultiple.php | 3 ++- application/Espo/Core/Webhook/Manager.php | 6 +++--- application/Espo/Core/Webhook/Queue.php | 3 ++- application/Espo/Entities/Email.php | 4 ++-- application/Espo/Entities/Export.php | 3 ++- application/Espo/Entities/MassAction.php | 5 +++-- application/Espo/Entities/Note.php | 5 +++-- application/Espo/Entities/Sms.php | 2 +- application/Espo/Entities/TwoFactorCode.php | 3 ++- application/Espo/Entities/UniqueId.php | 3 ++- .../Business/Distribution/Lead/RoundRobin.php | 3 ++- application/Espo/Modules/Crm/Entities/Call.php | 9 +++++---- .../Espo/Modules/Crm/Entities/Meeting.php | 4 ++-- .../Espo/Modules/Crm/Hooks/Meeting/Users.php | 7 ++++--- .../Modules/Crm/Tools/Activities/Service.php | 15 ++++++++------- .../Modules/Crm/Tools/Calendar/Service.php | 18 +++++++++--------- .../Modules/Crm/Tools/Lead/ConvertService.php | 13 +++++++------ .../Crm/Tools/MassEmail/UnsubscribeService.php | 3 ++- .../Crm/Tools/TargetList/OptOutService.php | 7 ++++--- .../Espo/Tools/ActionHistory/Service.php | 5 +++-- .../Jobs/CheckNewExtensionVersion.php | 3 ++- .../Espo/Tools/AdminNotifications/Manager.php | 3 ++- .../EmailNotification/AssignmentProcessor.php | 3 ++- .../Tools/EmailNotification/HookProcessor.php | 7 ++++--- .../Hook/Hooks/AssignedUsersUpdateHook.php | 5 +++-- application/Espo/Tools/Import/Service.php | 3 ++- .../Espo/Tools/Notification/Service.php | 3 ++- application/Espo/Tools/Stars/StarService.php | 3 ++- .../Espo/Tools/Stream/Api/GetGlobal.php | 3 ++- .../Espo/Tools/Stream/HookProcessor.php | 7 ++++--- .../Espo/Tools/Stream/NoteAcl/Processor.php | 2 +- .../Tools/Stream/RecordService/QueryHelper.php | 3 ++- application/Espo/Tools/Stream/Service.php | 2 +- 53 files changed, 147 insertions(+), 104 deletions(-) diff --git a/application/Espo/Classes/Acl/Email/AccessChecker.php b/application/Espo/Classes/Acl/Email/AccessChecker.php index 23811d7b2f..6e305b44c9 100644 --- a/application/Espo/Classes/Acl/Email/AccessChecker.php +++ b/application/Espo/Classes/Acl/Email/AccessChecker.php @@ -29,6 +29,7 @@ namespace Espo\Classes\Acl\Email; +use Espo\Core\Name\Field; use Espo\Entities\User; use Espo\Entities\Email; use Espo\ORM\Entity; @@ -100,12 +101,11 @@ class AccessChecker implements AccessEntityCREDSChecker return true; } - /** @var string[] $assignedUserIdList */ - $assignedUserIdList = $entity->getLinkMultipleIdList('assignedUsers'); + $assignedUserIdList = $entity->getLinkMultipleIdList(Field::ASSIGNED_USERS); if ( count($assignedUserIdList) === 1 && - $entity->hasLinkMultipleId('assignedUsers', $user->getId()) + $entity->hasLinkMultipleId(Field::ASSIGNED_USERS, $user->getId()) ) { return true; } diff --git a/application/Espo/Classes/Acl/Note/AccessChecker.php b/application/Espo/Classes/Acl/Note/AccessChecker.php index 0b8fc8024e..30914bed25 100644 --- a/application/Espo/Classes/Acl/Note/AccessChecker.php +++ b/application/Espo/Classes/Acl/Note/AccessChecker.php @@ -168,7 +168,7 @@ class AccessChecker implements AccessEntityCREDChecker return false; } - $createdAt = $entity->get('createdAt'); + $createdAt = $entity->get(Field::CREATED_AT); if (!$createdAt) { return true; @@ -209,7 +209,7 @@ class AccessChecker implements AccessEntityCREDChecker return false; } - $createdAt = $entity->get('createdAt'); + $createdAt = $entity->get(Field::CREATED_AT); if (!$createdAt) { return true; diff --git a/application/Espo/Classes/AclPortal/Note/AccessChecker.php b/application/Espo/Classes/AclPortal/Note/AccessChecker.php index 44c62c9aa0..3d590387e0 100644 --- a/application/Espo/Classes/AclPortal/Note/AccessChecker.php +++ b/application/Espo/Classes/AclPortal/Note/AccessChecker.php @@ -29,6 +29,7 @@ namespace Espo\Classes\AclPortal\Note; +use Espo\Core\Name\Field; use Espo\Entities\Note; use Espo\Entities\User; use Espo\ORM\Entity; @@ -137,7 +138,7 @@ class AccessChecker implements AccessEntityCREDChecker return false; } - $createdAt = $entity->get('createdAt'); + $createdAt = $entity->get(Field::CREATED_AT); if (!$createdAt) { return true; @@ -174,7 +175,7 @@ class AccessChecker implements AccessEntityCREDChecker return false; } - $createdAt = $entity->get('createdAt'); + $createdAt = $entity->get(Field::CREATED_AT); if (!$createdAt) { return true; diff --git a/application/Espo/Classes/Cleanup/Subscribers.php b/application/Espo/Classes/Cleanup/Subscribers.php index 70a573ec73..cd5b4c07da 100644 --- a/application/Espo/Classes/Cleanup/Subscribers.php +++ b/application/Espo/Classes/Cleanup/Subscribers.php @@ -31,6 +31,7 @@ namespace Espo\Classes\Cleanup; use Espo\Core\Cleanup\Cleanup; use Espo\Core\Field\DateTime; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Utils\Metadata; use Espo\Entities\StreamSubscription; @@ -77,7 +78,7 @@ class Subscribers implements Cleanup } /** @var string $dateField */ - $dateField = $data['dateField'] ?? 'createdAt'; + $dateField = $data['dateField'] ?? Field::CREATED_AT; /** @var ?string[] $statusList */ $statusList = $data['statusList'] ?? null; /** @var ?string $statusField */ diff --git a/application/Espo/Classes/ConsoleCommands/PopulateNumbers.php b/application/Espo/Classes/ConsoleCommands/PopulateNumbers.php index 3b6d944c09..3ebe538be7 100644 --- a/application/Espo/Classes/ConsoleCommands/PopulateNumbers.php +++ b/application/Espo/Classes/ConsoleCommands/PopulateNumbers.php @@ -36,6 +36,7 @@ use Espo\Core\Console\Exceptions\InvalidArgument; use Espo\Core\Console\IO; use Espo\Core\Exceptions\Error; use Espo\Core\FieldProcessing\NextNumber\BeforeSaveProcessor; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity as CoreEntity; use Espo\Core\ORM\Repository\Option\SaveOption; use Espo\ORM\EntityManager; @@ -62,7 +63,7 @@ class PopulateNumbers implements Command $entityType = $params->getArgument(0); $field = $params->getArgument(1); - $orderBy = $params->getOption('orderBy') ?? 'createdAt'; + $orderBy = $params->getOption('orderBy') ?? Field::CREATED_AT; $order = strtoupper($params->getOption('order') ?? Order::ASC); if (!$entityType) { diff --git a/application/Espo/Classes/DefaultLayouts/DefaultSidePanelType.php b/application/Espo/Classes/DefaultLayouts/DefaultSidePanelType.php index 34dfcf91a0..9af1b4b6a5 100644 --- a/application/Espo/Classes/DefaultLayouts/DefaultSidePanelType.php +++ b/application/Espo/Classes/DefaultLayouts/DefaultSidePanelType.php @@ -52,8 +52,8 @@ class DefaultSidePanelType $this->metadata->get(['entityDefs', $scope, 'fields', 'assignedUser', 'type']) === FieldType::LINK && $this->metadata->get(['entityDefs', $scope, 'links', 'assignedUser', 'entity']) === User::ENTITY_TYPE || - $this->metadata->get(['entityDefs', $scope, 'fields', 'assignedUsers', 'type']) === FieldType::LINK_MULTIPLE && - $this->metadata->get(['entityDefs', $scope, 'links', 'assignedUsers', 'entity']) === User::ENTITY_TYPE + $this->metadata->get(['entityDefs', $scope, 'fields', Field::ASSIGNED_USERS, 'type']) === FieldType::LINK_MULTIPLE && + $this->metadata->get(['entityDefs', $scope, 'links', Field::ASSIGNED_USERS, 'entity']) === User::ENTITY_TYPE ) { $list[] = (object) ['name' => ':assignedUser']; } diff --git a/application/Espo/Classes/FieldProcessing/User/LastAccessLoader.php b/application/Espo/Classes/FieldProcessing/User/LastAccessLoader.php index 4967260209..521ea83cc2 100644 --- a/application/Espo/Classes/FieldProcessing/User/LastAccessLoader.php +++ b/application/Espo/Classes/FieldProcessing/User/LastAccessLoader.php @@ -29,6 +29,7 @@ namespace Espo\Classes\FieldProcessing\User; +use Espo\Core\Name\Field; use Espo\Entities\AuthLogRecord; use Espo\Entities\AuthToken; use Espo\Entities\User; @@ -96,13 +97,13 @@ class LastAccessLoader implements Loader $authLogRecord = $this->entityManager ->getRDBRepository(AuthLogRecord::ENTITY_TYPE) - ->select(['id', 'createdAt']) + ->select(['id', Field::CREATED_AT]) ->where($where) ->order('requestTime', true) ->findOne(); if ($authLogRecord) { - $lastAccess = $authLogRecord->get('createdAt'); + $lastAccess = $authLogRecord->get(Field::CREATED_AT); } $entity->set('lastAccess', $lastAccess); diff --git a/application/Espo/Classes/Jobs/Cleanup.php b/application/Espo/Classes/Jobs/Cleanup.php index 6ee703f8b7..29bbdf6bfa 100644 --- a/application/Espo/Classes/Jobs/Cleanup.php +++ b/application/Espo/Classes/Jobs/Cleanup.php @@ -32,6 +32,7 @@ namespace Espo\Classes\Jobs; use Espo\Core\Exceptions\BadRequest; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Job\Job\Status as JobStatus; +use Espo\Core\Name\Field; use Espo\Core\ORM\Type\FieldType; use Espo\Core\Record\ServiceContainer; use Espo\Core\Utils\DateTime as DateTimeUtil; @@ -186,7 +187,7 @@ class Cleanup implements JobDataLess ->where([ 'scheduledJobId' => $scheduledJobId, ]) - ->order('createdAt', 'DESC') + ->order(Field::CREATED_AT, 'DESC') ->limit(0, 10) ->find(); @@ -355,7 +356,7 @@ class Cleanup implements JobDataLess continue; } - if (!$this->metadata->get(['entityDefs', $scope, 'fields', 'modifiedAt'])) { + if (!$this->metadata->get(['entityDefs', $scope, 'fields', Field::MODIFIED_AT])) { continue; } @@ -767,9 +768,9 @@ class Cleanup implements JobDataLess continue; } - if ($this->metadata->get(['entityDefs', $scope, 'fields', 'modifiedAt'])) { + if ($this->metadata->get(['entityDefs', $scope, 'fields', Field::MODIFIED_AT])) { $whereClause['modifiedAt<'] = $datetime->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT); - } else if ($this->metadata->get(['entityDefs', $scope, 'fields', 'createdAt'])) { + } else if ($this->metadata->get(['entityDefs', $scope, 'fields', Field::CREATED_AT])) { $whereClause['createdAt<'] = $datetime->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT); } diff --git a/application/Espo/Classes/Jobs/SendScheduledEmails.php b/application/Espo/Classes/Jobs/SendScheduledEmails.php index 42716586c0..01c775722b 100644 --- a/application/Espo/Classes/Jobs/SendScheduledEmails.php +++ b/application/Espo/Classes/Jobs/SendScheduledEmails.php @@ -37,6 +37,7 @@ use Espo\Core\Field\DateTime; use Espo\Core\Job\JobDataLess; use Espo\Core\Mail\Exceptions\NoSmtp; use Espo\Core\Mail\Exceptions\SendingError; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Utils\Language; use Espo\Core\Utils\Log; @@ -74,7 +75,7 @@ class SendScheduledEmails implements JobDataLess 'sendAt<' => DateTime::createNow()->toString(), ]) ->order('sendAt') - ->order('createdAt') + ->order(Field::CREATED_AT) ->limit(0, $this->getPortion()) ->sth() ->find(); diff --git a/application/Espo/Controllers/Notification.php b/application/Espo/Controllers/Notification.php index 1bff60a932..dc49f571fd 100644 --- a/application/Espo/Controllers/Notification.php +++ b/application/Espo/Controllers/Notification.php @@ -29,6 +29,7 @@ namespace Espo\Controllers; +use Espo\Core\Name\Field; use Espo\Tools\Notification\RecordService as Service; use Espo\Core\Api\Request; @@ -70,7 +71,7 @@ class Notification extends RecordBase ->withWhereAdded( WhereItem ::createBuilder() - ->setAttribute('createdAt') + ->setAttribute(Field::CREATED_AT) ->setType(WhereItem\Type::AFTER) ->setValue($after) ->build() diff --git a/application/Espo/Controllers/Stream.php b/application/Espo/Controllers/Stream.php index 7a42eb1d88..3ac4cea061 100644 --- a/application/Espo/Controllers/Stream.php +++ b/application/Espo/Controllers/Stream.php @@ -35,6 +35,7 @@ use Espo\Core\Api\Request; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Exceptions\NotFound; use Espo\Core\Field\DateTime; +use Espo\Core\Name\Field; use Espo\Core\Record\SearchParamsFetcher; use Espo\Core\Select\SearchParams; @@ -171,7 +172,7 @@ class Stream ->withWhereAdded( WhereItem ::createBuilder() - ->setAttribute('createdAt') + ->setAttribute(Field::CREATED_AT) ->setType(WhereItem\Type::AFTER) ->setValue($after) ->build() diff --git a/application/Espo/Core/Authentication/AuthToken/EspoManager.php b/application/Espo/Core/Authentication/AuthToken/EspoManager.php index 85361a600d..1bfa12da22 100644 --- a/application/Espo/Core/Authentication/AuthToken/EspoManager.php +++ b/application/Espo/Core/Authentication/AuthToken/EspoManager.php @@ -29,6 +29,7 @@ namespace Espo\Core\Authentication\AuthToken; +use Espo\Core\Name\Field; use Espo\ORM\EntityManager; use Espo\ORM\Repository\RDBRepository; use Espo\Entities\AuthToken as AuthTokenEntity; @@ -67,9 +68,9 @@ class EspoManager implements Manager 'userId', 'portalId', 'hash', - 'createdAt', + Field::CREATED_AT, 'lastAccess', - 'modifiedAt', + Field::MODIFIED_AT, ]) ->where(['token' => $token]) ->findOne(); diff --git a/application/Espo/Core/Authentication/TwoFactor/Email/Util.php b/application/Espo/Core/Authentication/TwoFactor/Email/Util.php index 598bd5ca24..526f134785 100644 --- a/application/Espo/Core/Authentication/TwoFactor/Email/Util.php +++ b/application/Espo/Core/Authentication/TwoFactor/Email/Util.php @@ -31,6 +31,7 @@ namespace Espo\Core\Authentication\TwoFactor\Email; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Mail\Exceptions\SendingError; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Mail\EmailSender; use Espo\Core\Mail\EmailFactory; @@ -244,7 +245,7 @@ class Util Cond::and( Cond::equal(Cond::column('method'), 'Email'), Cond::equal(Cond::column('userId'), $user->getId()), - Cond::greaterOrEqual(Cond::column('createdAt'), $from), + Cond::greaterOrEqual(Cond::column(Field::CREATED_AT), $from), Cond::lessOrEqual(Cond::column('attemptsLeft'), 0), ) ) diff --git a/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php b/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php index 17c601588b..d548d56bc4 100644 --- a/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php +++ b/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php @@ -30,6 +30,7 @@ namespace Espo\Core\Authentication\TwoFactor\Sms; use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Sms\SmsSender; use Espo\Core\Sms\SmsFactory; @@ -238,7 +239,7 @@ class Util Cond::and( Cond::equal(Cond::column('method'), self::METHOD), Cond::equal(Cond::column('userId'), $user->getId()), - Cond::greaterOrEqual(Cond::column('createdAt'), $from), + Cond::greaterOrEqual(Cond::column(Field::CREATED_AT), $from), Cond::lessOrEqual(Cond::column('attemptsLeft'), 0), ) ) diff --git a/application/Espo/Core/FieldProcessing/Reminder/Saver.php b/application/Espo/Core/FieldProcessing/Reminder/Saver.php index 95ed5fc72a..f16d4bfbae 100644 --- a/application/Espo/Core/FieldProcessing/Reminder/Saver.php +++ b/application/Espo/Core/FieldProcessing/Reminder/Saver.php @@ -30,6 +30,7 @@ namespace Espo\Core\FieldProcessing\Reminder; use Espo\Core\Field\DateTime; +use Espo\Core\Name\Field; use Espo\Core\Utils\Id\RecordIdGenerator; use Espo\Core\Utils\Metadata; use Espo\Entities\Preferences; @@ -177,7 +178,10 @@ class Saver implements SaverInterface return $entity->isNew() || $this->toReCreate($entity) || $entity->isAttributeChanged('assignedUserId') || - ($entity->hasLinkMultipleField('assignedUsers') && $entity->isAttributeChanged('assignedUsersIds')) || + ( + $entity->hasLinkMultipleField(Field::ASSIGNED_USERS) && + $entity->isAttributeChanged(Field::ASSIGNED_USERS . 'Ids') + ) || ($entity->hasLinkMultipleField('users') && $entity->isAttributeChanged('usersIds')) || $entity->isAttributeChanged($dateAttribute); } @@ -248,8 +252,8 @@ class Saver implements SaverInterface return $entity->getLinkMultipleIdList('users'); } - if ($entity->hasLinkMultipleField('assignedUsers')) { - return $entity->getLinkMultipleIdList('assignedUsers'); + if ($entity->hasLinkMultipleField(Field::ASSIGNED_USERS)) { + return $entity->getLinkMultipleIdList(Field::ASSIGNED_USERS); } $userIdList = []; diff --git a/application/Espo/Core/Mail/Account/GroupAccount/Hooks/AfterFetch.php b/application/Espo/Core/Mail/Account/GroupAccount/Hooks/AfterFetch.php index 3845fd3442..693f8a7612 100644 --- a/application/Espo/Core/Mail/Account/GroupAccount/Hooks/AfterFetch.php +++ b/application/Espo/Core/Mail/Account/GroupAccount/Hooks/AfterFetch.php @@ -407,8 +407,8 @@ class AfterFetch implements AfterFetchInterface { $userIdList = []; - if ($case->hasLinkMultipleField('assignedUsers')) { - $userIdList = $case->getLinkMultipleIdList('assignedUsers'); + if ($case->hasLinkMultipleField(Field::ASSIGNED_USERS)) { + $userIdList = $case->getLinkMultipleIdList(Field::ASSIGNED_USERS); } else { $assignedUserLink = $case->getAssignedUser(); diff --git a/application/Espo/Core/Mail/Importer/DefaultImporter.php b/application/Espo/Core/Mail/Importer/DefaultImporter.php index 6bef5be4ba..b96e6702b4 100644 --- a/application/Espo/Core/Mail/Importer/DefaultImporter.php +++ b/application/Espo/Core/Mail/Importer/DefaultImporter.php @@ -372,7 +372,7 @@ class DefaultImporter implements Importer ]); $this->linkMultipleSaver->process($email, 'users', $saverParams); - $this->linkMultipleSaver->process($email, 'assignedUsers', $saverParams); + $this->linkMultipleSaver->process($email, Field::ASSIGNED_USERS, $saverParams); $this->linkMultipleSaver->process($email, Field::TEAMS, $saverParams); if ($this->notificationsEnabled()) { diff --git a/application/Espo/Core/Notification/DefaultAssignmentNotificator.php b/application/Espo/Core/Notification/DefaultAssignmentNotificator.php index 3ce20d98b6..25d398c423 100644 --- a/application/Espo/Core/Notification/DefaultAssignmentNotificator.php +++ b/application/Espo/Core/Notification/DefaultAssignmentNotificator.php @@ -29,6 +29,7 @@ namespace Espo\Core\Notification; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity as CoreEntity; use Espo\ORM\Entity; use Espo\ORM\EntityManager; @@ -43,7 +44,7 @@ class DefaultAssignmentNotificator implements AssignmentNotificator { public const OPTION_FORCE_ASSIGNED_USER = 'forceAssignedUser'; - private const FIELD_ASSIGNED_USERS = 'assignedUsers'; + private const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS; private const ATTR_ASSIGNED_USER_ID = 'assignedUserId'; public function __construct( diff --git a/application/Espo/Core/Select/Bool/Filters/OnlyMy.php b/application/Espo/Core/Select/Bool/Filters/OnlyMy.php index 959f51a67a..a7bc40b847 100644 --- a/application/Espo/Core/Select/Bool/Filters/OnlyMy.php +++ b/application/Espo/Core/Select/Bool/Filters/OnlyMy.php @@ -29,6 +29,7 @@ namespace Espo\Core\Select\Bool\Filters; +use Espo\Core\Name\Field; use Espo\Core\Select\Bool\Filter; use Espo\Core\Select\Helpers\FieldHelper; use Espo\Entities\User; @@ -67,7 +68,7 @@ class OnlyMy implements Filter if ($this->fieldHelper->hasAssignedUsersField()) { $relationDefs = $this->defs ->getEntity($this->entityType) - ->getRelation('assignedUsers'); + ->getRelation(Field::ASSIGNED_USERS); $middleEntityType = ucfirst($relationDefs->getRelationshipName()); $key1 = $relationDefs->getMidKey(); diff --git a/application/Espo/Core/Select/Helpers/RelationQueryHelper.php b/application/Espo/Core/Select/Helpers/RelationQueryHelper.php index dc5251449b..be67e2886a 100644 --- a/application/Espo/Core/Select/Helpers/RelationQueryHelper.php +++ b/application/Espo/Core/Select/Helpers/RelationQueryHelper.php @@ -51,7 +51,7 @@ class RelationQueryHelper return $this->prepareRelatedUsersWhere( $entityType, $userId, - 'assignedUsers', + Field::ASSIGNED_USERS, User::RELATIONSHIP_ENTITY_USER ); } diff --git a/application/Espo/Core/Utils/Database/Orm/FieldConverters/AttachmentMultiple.php b/application/Espo/Core/Utils/Database/Orm/FieldConverters/AttachmentMultiple.php index e667d384f5..4548c83a0b 100644 --- a/application/Espo/Core/Utils/Database/Orm/FieldConverters/AttachmentMultiple.php +++ b/application/Espo/Core/Utils/Database/Orm/FieldConverters/AttachmentMultiple.php @@ -29,6 +29,7 @@ namespace Espo\Core\Utils\Database\Orm\FieldConverters; +use Espo\Core\Name\Field; use Espo\Core\ORM\Defs\AttributeParam; use Espo\Core\Utils\Database\Orm\Defs\AttributeDefs; use Espo\Core\Utils\Database\Orm\Defs\EntityDefs; @@ -50,7 +51,7 @@ class AttachmentMultiple implements FieldConverter ->withNotStorable() ->withParamsMerged([ 'orderBy' => [ - ['createdAt', Order::ASC], + [Field::CREATED_AT, Order::ASC], ['name', Order::ASC], ], AttributeParam::IS_LINK_MULTIPLE_ID_LIST => true, diff --git a/application/Espo/Core/Webhook/Manager.php b/application/Espo/Core/Webhook/Manager.php index 125d8ad78e..f37fe3bda8 100644 --- a/application/Espo/Core/Webhook/Manager.php +++ b/application/Espo/Core/Webhook/Manager.php @@ -29,13 +29,13 @@ namespace Espo\Core\Webhook; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use Espo\Core\ORM\EntityManager; use Espo\Core\Utils\Config; use Espo\Core\Utils\DataCache; use Espo\Core\Utils\FieldUtil; use Espo\Core\Utils\Log; - use Espo\Entities\Webhook; use Espo\Entities\WebhookEventQueueItem; @@ -51,8 +51,8 @@ class Manager /** @var string[] */ protected $skipAttributeList = [ 'isFollowed', - 'modifiedAt', - 'modifiedBy' + Field::MODIFIED_AT, + Field::MODIFIED_BY, ]; /** @var ?array */ diff --git a/application/Espo/Core/Webhook/Queue.php b/application/Espo/Core/Webhook/Queue.php index cbdeaad4a4..eb30844454 100644 --- a/application/Espo/Core/Webhook/Queue.php +++ b/application/Espo/Core/Webhook/Queue.php @@ -30,6 +30,7 @@ namespace Espo\Core\Webhook; use Espo\Core\Field\DateTime; +use Espo\Core\Name\Field; use Espo\Entities\User; use Espo\Entities\Webhook; use Espo\Entities\WebhookEventQueueItem; @@ -99,7 +100,7 @@ class Queue 'event' => $item->get('event'), 'isActive' => true, ]) - ->order('createdAt') + ->order(Field::CREATED_AT) ->find(); foreach ($webhookList as $webhook) { diff --git a/application/Espo/Entities/Email.php b/application/Espo/Entities/Email.php index a26dab583f..c6395edaf1 100644 --- a/application/Espo/Entities/Email.php +++ b/application/Espo/Entities/Email.php @@ -697,7 +697,7 @@ class Email extends Entity public function getAssignedUsers(): LinkMultiple { /** @var LinkMultiple */ - return $this->getValueObject('assignedUsers'); + return $this->getValueObject(Field::ASSIGNED_USERS); } public function getAssignedUser(): ?Link @@ -823,7 +823,7 @@ class Email extends Entity public function addAssignedUserId(string $assignedUserId): self { - $this->addLinkMultipleId('assignedUsers', $assignedUserId); + $this->addLinkMultipleId(Field::ASSIGNED_USERS, $assignedUserId); return $this; } diff --git a/application/Espo/Entities/Export.php b/application/Espo/Entities/Export.php index 96f45876d9..7247d2c794 100644 --- a/application/Espo/Entities/Export.php +++ b/application/Espo/Entities/Export.php @@ -29,6 +29,7 @@ namespace Espo\Entities; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use Espo\Core\Field\DateTime; use Espo\Core\Field\Link; @@ -87,7 +88,7 @@ class Export extends Entity public function getCreatedAt(): DateTime { - $value = $this->getValueObject('createdAt'); + $value = $this->getValueObject(Field::CREATED_AT); if (!$value instanceof DateTime) { throw new RuntimeException("No 'createdAt'."); diff --git a/application/Espo/Entities/MassAction.php b/application/Espo/Entities/MassAction.php index 80c68adaa9..987839bc37 100644 --- a/application/Espo/Entities/MassAction.php +++ b/application/Espo/Entities/MassAction.php @@ -29,6 +29,7 @@ namespace Espo\Entities; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use Espo\Core\Field\DateTime; use Espo\Core\Field\Link; @@ -117,7 +118,7 @@ class MassAction extends Entity public function getCreatedAt(): DateTime { - $value = $this->getValueObject('createdAt'); + $value = $this->getValueObject(Field::CREATED_AT); if (!$value instanceof DateTime) { throw new RuntimeException("No 'createdAt'."); @@ -128,7 +129,7 @@ class MassAction extends Entity public function getCreatedBy(): Link { - $value = $this->getValueObject('createdBy'); + $value = $this->getValueObject(Field::CREATED_BY); if (!$value instanceof Link) { throw new RuntimeException("No 'createdBy'."); diff --git a/application/Espo/Entities/Note.php b/application/Espo/Entities/Note.php index 5417380fa4..6e4c2bde5d 100644 --- a/application/Espo/Entities/Note.php +++ b/application/Espo/Entities/Note.php @@ -30,6 +30,7 @@ namespace Espo\Entities; use Espo\Core\Field\LinkParent; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use Espo\Core\Field\DateTime; @@ -135,7 +136,7 @@ class Note extends Entity public function getCreatedAt(): ?DateTime { /** @var ?DateTime */ - return $this->getValueObject('createdAt'); + return $this->getValueObject(Field::CREATED_AT); } public function setAclIsProcessed(): void @@ -167,7 +168,7 @@ class Note extends Entity $collection = $this->entityManager ->getRDBRepository(Attachment::ENTITY_TYPE) ->select(['id', 'name', 'type']) - ->order('createdAt') + ->order(Field::CREATED_AT) ->where([ 'id' => $attachmentsIds ]) diff --git a/application/Espo/Entities/Sms.php b/application/Espo/Entities/Sms.php index 1e6d8a889c..4e369dbd5a 100644 --- a/application/Espo/Entities/Sms.php +++ b/application/Espo/Entities/Sms.php @@ -58,7 +58,7 @@ class Sms extends Entity implements SmsInterface public function getCreatedAt(): ?DateTime { /** @var ?DateTime */ - return $this->getValueObject('createdAt'); + return $this->getValueObject(Field::CREATED_AT); } public function getBody(): string diff --git a/application/Espo/Entities/TwoFactorCode.php b/application/Espo/Entities/TwoFactorCode.php index 3822456da0..941ab18ad2 100644 --- a/application/Espo/Entities/TwoFactorCode.php +++ b/application/Espo/Entities/TwoFactorCode.php @@ -30,6 +30,7 @@ namespace Espo\Entities; use Espo\Core\Field\DateTime; +use Espo\Core\Name\Field; class TwoFactorCode extends \Espo\Core\ORM\Entity { @@ -43,7 +44,7 @@ class TwoFactorCode extends \Espo\Core\ORM\Entity public function getCreatedAt(): DateTime { /** @var DateTime */ - return $this->getValueObject('createdAt'); + return $this->getValueObject(Field::CREATED_AT); } public function getCode(): string diff --git a/application/Espo/Entities/UniqueId.php b/application/Espo/Entities/UniqueId.php index 642ddb9d2b..7834f010a8 100644 --- a/application/Espo/Entities/UniqueId.php +++ b/application/Espo/Entities/UniqueId.php @@ -31,6 +31,7 @@ namespace Espo\Entities; use Espo\Core\Field\DateTime; use Espo\Core\Field\LinkParent; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use stdClass; @@ -59,7 +60,7 @@ class UniqueId extends Entity public function getCreatedAt(): DateTime { /** @var ?DateTime $value */ - $value = $this->getValueObject('createdAt'); + $value = $this->getValueObject(Field::CREATED_AT); if (!$value) { throw new LogicException(); diff --git a/application/Espo/Modules/Crm/Business/Distribution/Lead/RoundRobin.php b/application/Espo/Modules/Crm/Business/Distribution/Lead/RoundRobin.php index 8ccd468353..9b707ed391 100644 --- a/application/Espo/Modules/Crm/Business/Distribution/Lead/RoundRobin.php +++ b/application/Espo/Modules/Crm/Business/Distribution/Lead/RoundRobin.php @@ -29,6 +29,7 @@ namespace Espo\Modules\Crm\Business\Distribution\Lead; +use Espo\Core\Name\Field; use Espo\Modules\Crm\Entities\Lead; use Espo\ORM\EntityManager; @@ -87,7 +88,7 @@ class RoundRobin ->where([ 'assignedUserId' => $userIdList ]) - ->order('createdAt', 'DESC') + ->order(Field::CREATED_AT, 'DESC') ->findOne(); if (empty($lead)) { diff --git a/application/Espo/Modules/Crm/Entities/Call.php b/application/Espo/Modules/Crm/Entities/Call.php index 3ac6ff2775..dc89be4d5b 100644 --- a/application/Espo/Modules/Crm/Entities/Call.php +++ b/application/Espo/Modules/Crm/Entities/Call.php @@ -33,6 +33,7 @@ use Espo\Core\Field\DateTime; use Espo\Core\Field\Link; use Espo\Core\Field\LinkMultiple; use Espo\Core\Field\LinkParent; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use Espo\Entities\User; @@ -90,25 +91,25 @@ class Call extends Entity public function getCreatedBy(): ?Link { /** @var ?Link */ - return $this->getValueObject('createdBy'); + return $this->getValueObject(Field::CREATED_BY); } public function getModifiedBy(): ?Link { /** @var ?Link */ - return $this->getValueObject('modifiedBy'); + return $this->getValueObject(Field::MODIFIED_BY); } public function getAssignedUser(): ?Link { /** @var ?Link */ - return $this->getValueObject('assignedUser'); + return $this->getValueObject(Field::ASSIGNED_USER); } public function getTeams(): LinkMultiple { /** @var LinkMultiple */ - return $this->getValueObject('teams'); + return $this->getValueObject(Field::TEAMS); } public function getUsers(): LinkMultiple diff --git a/application/Espo/Modules/Crm/Entities/Meeting.php b/application/Espo/Modules/Crm/Entities/Meeting.php index 565ff0c6c0..bbacb3e247 100644 --- a/application/Espo/Modules/Crm/Entities/Meeting.php +++ b/application/Espo/Modules/Crm/Entities/Meeting.php @@ -96,13 +96,13 @@ class Meeting extends Entity public function getCreatedBy(): ?Link { /** @var ?Link */ - return $this->getValueObject('createdBy'); + return $this->getValueObject(Field::CREATED_BY); } public function getModifiedBy(): ?Link { /** @var ?Link */ - return $this->getValueObject('modifiedBy'); + return $this->getValueObject(Field::MODIFIED_BY); } public function getAssignedUser(): ?Link diff --git a/application/Espo/Modules/Crm/Hooks/Meeting/Users.php b/application/Espo/Modules/Crm/Hooks/Meeting/Users.php index 4ea7c0ba2f..81ee928b8d 100644 --- a/application/Espo/Modules/Crm/Hooks/Meeting/Users.php +++ b/application/Espo/Modules/Crm/Hooks/Meeting/Users.php @@ -30,6 +30,7 @@ namespace Espo\Modules\Crm\Hooks\Meeting; use Espo\Core\Hook\Hook\BeforeSave; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity as CoreEntity; use Espo\Core\Utils\Config; use Espo\Entities\User; @@ -55,15 +56,15 @@ class Users implements BeforeSave public function beforeSave(Entity $entity, SaveOptions $options): void { if (!$this->config->get('eventAssignedUserIsAttendeeDisabled')) { - if ($entity->hasLinkMultipleField('assignedUsers')) { - $assignedUserIdList = $entity->getLinkMultipleIdList('assignedUsers'); + if ($entity->hasLinkMultipleField(Field::ASSIGNED_USERS)) { + $assignedUserIdList = $entity->getLinkMultipleIdList(Field::ASSIGNED_USERS); foreach ($assignedUserIdList as $assignedUserId) { $entity->addLinkMultipleId('users', $assignedUserId); $entity->setLinkMultipleName( 'users', $assignedUserId, - $entity->getLinkMultipleName('assignedUsers', $assignedUserId) + $entity->getLinkMultipleName(Field::ASSIGNED_USERS, $assignedUserId) ); } } else { diff --git a/application/Espo/Modules/Crm/Tools/Activities/Service.php b/application/Espo/Modules/Crm/Tools/Activities/Service.php index 1e57382fd9..1620afcfea 100644 --- a/application/Espo/Modules/Crm/Tools/Activities/Service.php +++ b/application/Espo/Modules/Crm/Tools/Activities/Service.php @@ -35,6 +35,7 @@ use Espo\Core\Exceptions\Error; use Espo\Core\Exceptions\NotFound; use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Name\Field; use Espo\Core\ServiceFactory; use Espo\Core\Templates\Entities\Company; use Espo\Core\Templates\Entities\Person; @@ -129,7 +130,7 @@ class Service 'parentType', 'parentId', 'status', - 'createdAt', + Field::CREATED_AT, ['null', 'hasAttachment'], ]) ->leftJoin( @@ -201,7 +202,7 @@ class Service 'parentType', 'parentId', 'status', - 'createdAt', + Field::CREATED_AT, ['null', 'hasAttachment'], ]) ->leftJoin( @@ -274,7 +275,7 @@ class Service 'parentType', 'parentId', 'status', - 'createdAt', + Field::CREATED_AT, 'hasAttachment', ]) ->leftJoin( @@ -347,7 +348,7 @@ class Service 'parentType', 'parentId', 'status', - 'createdAt', + Field::CREATED_AT, ['false', 'hasAttachment'], ]); } catch (BadRequest|Forbidden $e) { @@ -475,7 +476,7 @@ class Service 'parentType', 'parentId', 'status', - 'createdAt', + Field::CREATED_AT, 'hasAttachment', ]); } catch (BadRequest|Forbidden $e) { @@ -689,7 +690,7 @@ class Service if ($scope === User::ENTITY_TYPE) { $maxSizeQ++; } else { - $builder->order('createdAt', 'DESC'); + $builder->order(Field::CREATED_AT, 'DESC'); } if ($maxSize) { @@ -1072,7 +1073,7 @@ class Service ($seed->hasAttribute('parentType') ? ['parentType', 'parentType'] : ['null', 'parentType']), ($seed->hasAttribute('parentId') ? ['parentId', 'parentId'] : ['null', 'parentId']), 'status', - 'createdAt', + Field::CREATED_AT, ['false', 'hasAttachment'], ]); } catch (BadRequest|Forbidden $e) { diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Service.php b/application/Espo/Modules/Crm/Tools/Calendar/Service.php index c1f769d372..c92b994913 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Service.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Service.php @@ -255,7 +255,7 @@ class Service ($seed->hasAttribute('dateEndDate') ? ['dateEndDate', 'dateEndDate'] : ['null', 'dateEndDate']), ($seed->hasAttribute('parentType') ? ['parentType', 'parentType'] : ['null', 'parentType']), ($seed->hasAttribute('parentId') ? ['parentId', 'parentId'] : ['null', 'parentId']), - 'createdAt', + Field::CREATED_AT, ]; $additionalAttributeList = $this->metadata->get( @@ -276,7 +276,7 @@ class Service $orGroup['usersMiddle.userId'] = $userId; } - if ($seed->hasRelation('assignedUsers')) { + if ($seed->hasRelation(Field::ASSIGNED_USERS)) { $orGroup['assignedUsersMiddle.userId'] = $userId; } @@ -323,10 +323,10 @@ class Service ->leftJoin('users'); } - if ($seed->hasRelation('assignedUsers')) { + if ($seed->hasRelation(Field::ASSIGNED_USERS)) { $queryBuilder ->distinct() - ->leftJoin('assignedUsers'); + ->leftJoin(Field::ASSIGNED_USERS); } return $queryBuilder->build(); @@ -353,7 +353,7 @@ class Service ['dateEndDate', 'dateEndDate'], 'parentType', 'parentId', - 'createdAt', + Field::CREATED_AT, ]; $seed = $this->entityManager->getNewEntity(Meeting::ENTITY_TYPE); @@ -418,7 +418,7 @@ class Service ['null', 'dateEndDate'], 'parentType', 'parentId', - 'createdAt', + Field::CREATED_AT, ]; $seed = $this->entityManager->getNewEntity(Call::ENTITY_TYPE); @@ -483,7 +483,7 @@ class Service ['dateEndDate', 'dateEndDate'], 'parentType', 'parentId', - 'createdAt', + Field::CREATED_AT, ]; $seed = $this->entityManager->getNewEntity(Task::ENTITY_TYPE); @@ -525,9 +525,9 @@ class Service } if ( - $this->metadata->get(['entityDefs', 'Task', 'fields', 'assignedUsers', 'type']) === + $this->metadata->get(['entityDefs', 'Task', 'fields', Field::ASSIGNED_USERS, 'type']) === FieldType::LINK_MULTIPLE && - !$this->metadata->get(['entityDefs', 'Task', 'fields', 'assignedUsers', 'disabled']) + !$this->metadata->get(['entityDefs', 'Task', 'fields', Field::ASSIGNED_USERS, 'disabled']) ) { $queryBuilder->where( $this->relationQueryHelper->prepareAssignedUsersWhere(Task::ENTITY_TYPE, $userId) diff --git a/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php b/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php index a058581c13..714a2bf011 100644 --- a/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php +++ b/application/Espo/Modules/Crm/Tools/Lead/ConvertService.php @@ -35,6 +35,7 @@ use Espo\Core\Exceptions\Conflict; use Espo\Core\Exceptions\ConflictSilent; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Exceptions\NotFound; +use Espo\Core\Name\Field; use Espo\Core\ORM\Type\FieldType; use Espo\Core\Record\CreateParams; use Espo\Core\Record\ServiceContainer; @@ -148,12 +149,12 @@ class ConvertService $entityList = $this->metadata->get('entityDefs.Lead.convertEntityList', []); $ignoreAttributeList = [ - 'createdAt', - 'modifiedAt', - 'modifiedById', - 'modifiedByName', - 'createdById', - 'createdByName', + Field::CREATED_AT, + Field::MODIFIED_AT, + Field::MODIFIED_BY . 'Id', + Field::MODIFIED_BY . 'Name', + Field::CREATED_BY . 'Id', + Field::MODIFIED_BY . 'Name', ]; /** @var array> $convertFieldsDefs */ diff --git a/application/Espo/Modules/Crm/Tools/MassEmail/UnsubscribeService.php b/application/Espo/Modules/Crm/Tools/MassEmail/UnsubscribeService.php index cb82522755..02ff7d5f93 100644 --- a/application/Espo/Modules/Crm/Tools/MassEmail/UnsubscribeService.php +++ b/application/Espo/Modules/Crm/Tools/MassEmail/UnsubscribeService.php @@ -31,6 +31,7 @@ namespace Espo\Modules\Crm\Tools\MassEmail; use Espo\Core\Exceptions\NotFound; use Espo\Core\HookManager; +use Espo\Core\Name\Field; use Espo\Core\ORM\EntityManager; use Espo\Core\Utils\Hasher; use Espo\Entities\EmailAddress; @@ -174,7 +175,7 @@ class UnsubscribeService 'queueItemId' => $queueItemId, 'action' => CampaignLogRecord::ACTION_OPTED_OUT, ]) - ->order('createdAt', true) + ->order(Field::CREATED_AT, true) ->findOne(); if ($logRecord) { diff --git a/application/Espo/Modules/Crm/Tools/TargetList/OptOutService.php b/application/Espo/Modules/Crm/Tools/TargetList/OptOutService.php index 51415aed27..6c489d5c35 100644 --- a/application/Espo/Modules/Crm/Tools/TargetList/OptOutService.php +++ b/application/Espo/Modules/Crm/Tools/TargetList/OptOutService.php @@ -32,6 +32,7 @@ namespace Espo\Modules\Crm\Tools\TargetList; use Espo\Core\Exceptions\Forbidden; use Espo\Core\Exceptions\NotFound; use Espo\Core\HookManager; +use Espo\Core\Name\Field; use Espo\Core\Record\Collection; use Espo\Core\Record\Collection as RecordCollection; use Espo\Core\Record\EntityProvider; @@ -176,7 +177,7 @@ class OptOutService $unionQuery = $builder ->limit($offset, $maxSize) - ->order('createdAt', 'DESC') + ->order(Field::CREATED_AT, 'DESC') ->build(); $sth = $em->getQueryExecutor()->execute($unionQuery); @@ -228,7 +229,7 @@ class OptOutService ->select([ 'id', 'name', - 'createdAt', + Field::CREATED_AT, ["'$entityType'", 'entityType'], ]) ->join( @@ -241,7 +242,7 @@ class OptOutService 'j.targetListId' => $id, ] ) - ->order('createdAt', Order::DESC) + ->order(Field::CREATED_AT, Order::DESC) ->build(); } diff --git a/application/Espo/Tools/ActionHistory/Service.php b/application/Espo/Tools/ActionHistory/Service.php index 33907d0eb2..3b1df6b51d 100644 --- a/application/Espo/Tools/ActionHistory/Service.php +++ b/application/Espo/Tools/ActionHistory/Service.php @@ -29,6 +29,7 @@ namespace Espo\Tools\ActionHistory; +use Espo\Core\Name\Field; use Espo\Core\Record\ActionHistory\Action; use Espo\Core\Record\Collection as RecordCollection; use Espo\Entities\ActionHistoryRecord; @@ -71,12 +72,12 @@ class Service 'action' => Action::READ, 'targetType' => $targetTypeList, ]) - ->order('MAX:createdAt', 'DESC') + ->order('MAX:' . Field::CREATED_AT, 'DESC') ->select([ 'targetId', 'targetType', 'MAX:number', - ['MAX:createdAt', 'createdAt'], + ['MAX:createdAt', Field::CREATED_AT], ]) ->group(['targetId', 'targetType']) ->limit($offset, $maxSize + 1) diff --git a/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php b/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php index 62c5cfcf82..b644e542d8 100644 --- a/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php +++ b/application/Espo/Tools/AdminNotifications/Jobs/CheckNewExtensionVersion.php @@ -30,6 +30,7 @@ namespace Espo\Tools\AdminNotifications\Jobs; use Espo\Core\Job\JobDataLess; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Utils\Config\ConfigWriter; use Espo\Entities\Extension; @@ -66,7 +67,7 @@ class CheckNewExtensionVersion implements JobDataLess 'deleted' => false, 'isInstalled' => true, ]) - ->order(['createdAt']) + ->order([Field::CREATED_AT]) ->build(); $sth = $this->entityManager->getQueryExecutor()->execute($query); diff --git a/application/Espo/Tools/AdminNotifications/Manager.php b/application/Espo/Tools/AdminNotifications/Manager.php index 3c074876e5..aa3e861a24 100644 --- a/application/Espo/Tools/AdminNotifications/Manager.php +++ b/application/Espo/Tools/AdminNotifications/Manager.php @@ -29,6 +29,7 @@ namespace Espo\Tools\AdminNotifications; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Utils\Language; use Espo\Core\Utils\ScheduledJob; @@ -200,7 +201,7 @@ class Manager 'name' => $extensionName, 'isInstalled' => true, ]) - ->order('createdAt', true) + ->order(Field::CREATED_AT, true) ->findOne(); if (!$extension) { diff --git a/application/Espo/Tools/EmailNotification/AssignmentProcessor.php b/application/Espo/Tools/EmailNotification/AssignmentProcessor.php index 9ccdff3ba7..293a92d88e 100644 --- a/application/Espo/Tools/EmailNotification/AssignmentProcessor.php +++ b/application/Espo/Tools/EmailNotification/AssignmentProcessor.php @@ -29,6 +29,7 @@ namespace Espo\Tools\EmailNotification; +use Espo\Core\Name\Field; use Espo\Core\ORM\Entity; use Espo\Core\ORM\Type\FieldType; use Espo\Entities\Email; @@ -123,7 +124,7 @@ class AssignmentProcessor $this->loadParentNameFields($entity); - if (!$entity->hasLinkMultipleField('assignedUsers')) { + if (!$entity->hasLinkMultipleField(Field::ASSIGNED_USERS)) { if ($entity->get('assignedUserId') !== $userId) { return; } diff --git a/application/Espo/Tools/EmailNotification/HookProcessor.php b/application/Espo/Tools/EmailNotification/HookProcessor.php index 5f0214e493..7070c6acfb 100644 --- a/application/Espo/Tools/EmailNotification/HookProcessor.php +++ b/application/Espo/Tools/EmailNotification/HookProcessor.php @@ -29,6 +29,7 @@ namespace Espo\Tools\EmailNotification; +use Espo\Core\Name\Field; use Espo\ORM\Entity; use Espo\Core\ORM\Entity as CoreEntity; use Espo\Core\Utils\Config; @@ -76,8 +77,8 @@ class HookProcessor private function processMultiple(CoreEntity $entity): void { - $userIdList = $entity->getLinkMultipleIdList('assignedUsers'); - $fetchedAssignedUserIdList = $entity->getFetched('assignedUsersIds') ?? []; + $userIdList = $entity->getLinkMultipleIdList(Field::ASSIGNED_USERS); + $fetchedAssignedUserIdList = $entity->getFetched(Field::ASSIGNED_USERS . 'Ids') ?? []; foreach ($userIdList as $userId) { if ( @@ -99,7 +100,7 @@ class HookProcessor $hasAssignedUserField = $entity->has('assignedUserId') || - $entity->hasLinkMultipleField('assignedUsers') && + $entity->hasLinkMultipleField(Field::ASSIGNED_USERS) && $entity->has('assignedUsersIds'); if (!$hasAssignedUserField) { diff --git a/application/Espo/Tools/EntityManager/Hook/Hooks/AssignedUsersUpdateHook.php b/application/Espo/Tools/EntityManager/Hook/Hooks/AssignedUsersUpdateHook.php index ba8747caf4..ca99a39756 100644 --- a/application/Espo/Tools/EntityManager/Hook/Hooks/AssignedUsersUpdateHook.php +++ b/application/Espo/Tools/EntityManager/Hook/Hooks/AssignedUsersUpdateHook.php @@ -29,6 +29,7 @@ namespace Espo\Tools\EntityManager\Hook\Hooks; +use Espo\Core\Name\Field; use Espo\Core\ORM\Type\FieldType; use Espo\Core\Utils\Log; use Espo\Core\Utils\Metadata; @@ -43,9 +44,9 @@ use Espo\Tools\EntityManager\Params; class AssignedUsersUpdateHook implements UpdateHook { private const PARAM = 'assignedUsers'; - private const FIELD = 'assignedUsers'; + private const FIELD = Field::ASSIGNED_USERS; private const RELATION_NAME = 'entityUser'; - private const FIELD_ASSIGNED_USER = 'assignedUser'; + private const FIELD_ASSIGNED_USER = Field::ASSIGNED_USER; private const DEFAULT_MAX_COUNT = 10; diff --git a/application/Espo/Tools/Import/Service.php b/application/Espo/Tools/Import/Service.php index d1ef810ab9..84a212f18d 100644 --- a/application/Espo/Tools/Import/Service.php +++ b/application/Espo/Tools/Import/Service.php @@ -29,6 +29,7 @@ namespace Espo\Tools\Import; +use Espo\Core\Name\Field; use Exception; use GuzzleHttp\Psr7\Utils as Psr7Utils; @@ -227,7 +228,7 @@ class Service $removeFromDb = false; - $createdAt = $import->get('createdAt'); + $createdAt = $import->get(Field::CREATED_AT); if ($createdAt) { $dtNow = new DateTime(); diff --git a/application/Espo/Tools/Notification/Service.php b/application/Espo/Tools/Notification/Service.php index a5b90f8a16..b047cc4923 100644 --- a/application/Espo/Tools/Notification/Service.php +++ b/application/Espo/Tools/Notification/Service.php @@ -29,6 +29,7 @@ namespace Espo\Tools\Notification; +use Espo\Core\Name\Field; use Espo\Core\Utils\Id\RecordIdGenerator; use Espo\Entities\Note; use Espo\Entities\Notification; @@ -128,7 +129,7 @@ class Service ], 'type' => Notification::TYPE_NOTE, 'userId' => $userId, - 'createdAt' => $now, + Field::CREATED_AT => $now, 'relatedId' => $note->getId(), 'relatedType' => Note::ENTITY_TYPE, 'relatedParentId' => $note->getParentId(), diff --git a/application/Espo/Tools/Stars/StarService.php b/application/Espo/Tools/Stars/StarService.php index 72ddc66be5..cf5b7eb379 100644 --- a/application/Espo/Tools/Stars/StarService.php +++ b/application/Espo/Tools/Stars/StarService.php @@ -31,6 +31,7 @@ namespace Espo\Tools\Stars; use Espo\Core\Exceptions\Error\Body; use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Name\Field; use Espo\Core\Utils\Config; use Espo\Core\Utils\DateTime; use Espo\Core\Utils\Metadata; @@ -86,7 +87,7 @@ class StarService 'entityId' => $entity->getId(), 'entityType' => $entity->getEntityType(), 'userId' => $user->getId(), - 'createdAt' => DateTime::getSystemNowString(), + Field::CREATED_AT => DateTime::getSystemNowString(), ]); } catch (PDOException $e) { if ((int) $e->getCode() === 23000) { diff --git a/application/Espo/Tools/Stream/Api/GetGlobal.php b/application/Espo/Tools/Stream/Api/GetGlobal.php index c0c0bcec94..79a2e0a5a6 100644 --- a/application/Espo/Tools/Stream/Api/GetGlobal.php +++ b/application/Espo/Tools/Stream/Api/GetGlobal.php @@ -36,6 +36,7 @@ use Espo\Core\Api\Response; use Espo\Core\Api\ResponseComposer; use Espo\Core\Exceptions\BadRequest; use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Name\Field; use Espo\Core\Record\SearchParamsFetcher; use Espo\Core\Select\SearchParams; use Espo\Core\Select\Where\Item as WhereItem; @@ -83,7 +84,7 @@ class GetGlobal implements Action ->withWhereAdded( WhereItem ::createBuilder() - ->setAttribute('createdAt') + ->setAttribute(Field::CREATED_AT) ->setType(WhereItem\Type::AFTER) ->setValue($after) ->build() diff --git a/application/Espo/Tools/Stream/HookProcessor.php b/application/Espo/Tools/Stream/HookProcessor.php index e6769d684e..a136f83bbe 100644 --- a/application/Espo/Tools/Stream/HookProcessor.php +++ b/application/Espo/Tools/Stream/HookProcessor.php @@ -29,6 +29,7 @@ namespace Espo\Tools\Stream; +use Espo\Core\Name\Field; use Espo\Core\ORM\Repository\Option\SaveOption; use Espo\Core\ORM\Entity as CoreEntity; use Espo\Core\Utils\Metadata; @@ -62,7 +63,7 @@ class HookProcessor /** @var ?array */ private $statusFields = null; - private const FIELD_ASSIGNED_USERS = 'assignedUsers'; + private const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS; public function __construct( private Metadata $metadata, @@ -343,7 +344,7 @@ class HookProcessor $entityType = $entity->getEntityType(); $multipleField = $this->metadata->get(['streamDefs', $entityType, 'followingUsersField']) ?? - 'assignedUsers'; + Field::ASSIGNED_USERS; $hasAssignedUsersField = $entity->hasLinkMultipleField($multipleField); @@ -447,7 +448,7 @@ class HookProcessor } $multipleField = $this->metadata->get(['streamDefs', $entity->getEntityType(), 'followingUsersField']) ?? - 'assignedUsers'; + Field::ASSIGNED_USERS; if (!$entity->hasLinkMultipleField($multipleField)) { return; diff --git a/application/Espo/Tools/Stream/NoteAcl/Processor.php b/application/Espo/Tools/Stream/NoteAcl/Processor.php index cc663ab055..8fd21380b4 100644 --- a/application/Espo/Tools/Stream/NoteAcl/Processor.php +++ b/application/Espo/Tools/Stream/NoteAcl/Processor.php @@ -217,7 +217,7 @@ class Processor 'isInternal', 'relatedType', 'relatedId', - 'createdAt', + Field::CREATED_AT, ]) ->order('number', Order::DESC) ->limit(0, $limit) diff --git a/application/Espo/Tools/Stream/RecordService/QueryHelper.php b/application/Espo/Tools/Stream/RecordService/QueryHelper.php index 2a05d3863d..714130e57f 100644 --- a/application/Espo/Tools/Stream/RecordService/QueryHelper.php +++ b/application/Espo/Tools/Stream/RecordService/QueryHelper.php @@ -34,6 +34,7 @@ use Espo\Core\Acl\Table; use Espo\Core\AclManager; use Espo\Core\Exceptions\BadRequest; use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Name\Field; use Espo\Core\Select\SearchParams; use Espo\Core\Select\SelectBuilderFactory; use Espo\Entities\Note; @@ -102,7 +103,7 @@ class QueryHelper 'relatedType', 'relatedId', 'targetType', - 'createdAt', + Field::CREATED_AT, 'createdById', 'createdByName', 'isGlobal', diff --git a/application/Espo/Tools/Stream/Service.php b/application/Espo/Tools/Stream/Service.php index cf1ec5052e..0152e8359d 100644 --- a/application/Espo/Tools/Stream/Service.php +++ b/application/Espo/Tools/Stream/Service.php @@ -89,7 +89,7 @@ class Service 'Closed Lost', ]; - private const FIELD_ASSIGNED_USERS = 'assignedUsers'; + private const FIELD_ASSIGNED_USERS = Field::ASSIGNED_USERS; /** * @var array<