From 4aa4b17c9f18aaa23211371a99e7257ea7c37565 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 25 Apr 2024 14:42:22 +0300 Subject: [PATCH] ref --- .../Classes/RecordHooks/Note/BeforeCreate.php | 2 +- application/Espo/Entities/Note.php | 21 +++++++++++++++++++ application/Espo/Tools/Stream/Service.php | 12 +++++------ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/application/Espo/Classes/RecordHooks/Note/BeforeCreate.php b/application/Espo/Classes/RecordHooks/Note/BeforeCreate.php index 206a350c3f..94a1b52c14 100644 --- a/application/Espo/Classes/RecordHooks/Note/BeforeCreate.php +++ b/application/Espo/Classes/RecordHooks/Note/BeforeCreate.php @@ -87,7 +87,7 @@ class BeforeCreate implements SaveHook $entity->clear('usersIds'); $entity->clear('teamsIds'); $entity->clear('portalsIds'); - $entity->set('usersIds', [$this->user->getId()]); + $entity->setUsersIds([$this->user->getId()]); $entity->set('isForSelf', true); break; diff --git a/application/Espo/Entities/Note.php b/application/Espo/Entities/Note.php index 44370413c4..111a627fa2 100644 --- a/application/Espo/Entities/Note.php +++ b/application/Espo/Entities/Note.php @@ -29,6 +29,7 @@ namespace Espo\Entities; +use Espo\Core\Field\LinkMultiple; use Espo\Core\Field\LinkParent; use Espo\Core\ORM\Entity; @@ -306,4 +307,24 @@ class Note extends Entity } } } + + /** + * @param string[] $ids + */ + public function setTeamsIds(array $ids): self + { + $this->set('teamsIds', $ids); + + return $this; + } + + /** + * @param string[] $ids + */ + public function setUsersIds(array $ids): self + { + $this->set('usersIds', $ids); + + return $this; + } } diff --git a/application/Espo/Tools/Stream/Service.php b/application/Espo/Tools/Stream/Service.php index 841b48cbe5..9f66601a74 100644 --- a/application/Espo/Tools/Stream/Service.php +++ b/application/Espo/Tools/Stream/Service.php @@ -397,13 +397,13 @@ class Service $note->setAclIsProcessed(); - $note->set('teamsIds', []); - $note->set('usersIds', []); + $note->setTeamsIds([]); + $note->setUsersIds([]); if ($entity->hasLinkMultipleField('teams')) { $teamIdList = $entity->getLinkMultipleIdList('teams'); - $note->set('teamsIds', $teamIdList); + $note->setTeamsIds($teamIdList); } $ownerUserField = $this->aclManager->getReadOwnerUserField($entity->getEntityType()); @@ -447,7 +447,7 @@ class Service $userIdList = [$userId]; } - $note->set('usersIds', $userIdList); + $note->setUsersIds($userIdList); } public function noteEmailReceived(Entity $entity, Email $email, bool $isInitial = false): void @@ -1349,11 +1349,11 @@ class Service } if ($teamsAttributeIsChanged || $forceProcessNoteNotifications) { - $note->set('teamsIds', $teamIdList); + $note->setTeamsIds($teamIdList); } if ($usersAttributeIsChanged || $forceProcessNoteNotifications) { - $note->set('usersIds', $userIdList); + $note->setUsersIds($userIdList); } $this->entityManager->saveEntity($note, [