From 712f3a1cbdb174a5b0b04dad331ba71f84e9402e Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 3 Jul 2025 11:54:24 +0300 Subject: [PATCH] ref --- .../Relation/LinkMultipleSaver.php | 2 +- application/Espo/Hooks/Note/Notifications.php | 7 ++--- .../Espo/Tools/Notification/HookProcessor.php | 4 +-- application/Espo/Tools/Stream/Service.php | 28 +++++++++---------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php b/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php index 74108c2567..91edeae3ef 100644 --- a/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php +++ b/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php @@ -203,7 +203,7 @@ class LinkMultipleSaver } } - $saveContext = $params->getOption(SaveContext::NAME); + $saveContext = SaveContext::obtainFromRawOptions($params->getRawOptions()); foreach ($toCreateIdList as $id) { $data = null; diff --git a/application/Espo/Hooks/Note/Notifications.php b/application/Espo/Hooks/Note/Notifications.php index 12e57d2500..5ad08e2f59 100644 --- a/application/Espo/Hooks/Note/Notifications.php +++ b/application/Espo/Hooks/Note/Notifications.php @@ -53,12 +53,9 @@ class Notifications implements AfterSave return; } + $saveContext = SaveContext::obtainFromOptions($options); - $saveContext = $options->get(SaveContext::NAME); - - $actionId = $saveContext instanceof SaveContext ? $saveContext->getId() : null; - - $params = new Params(actionId: $actionId); + $params = new Params(actionId: $saveContext?->getId()); $this->processor->afterSave($entity, $params); } diff --git a/application/Espo/Tools/Notification/HookProcessor.php b/application/Espo/Tools/Notification/HookProcessor.php index 01a4065357..7c90a56b10 100644 --- a/application/Espo/Tools/Notification/HookProcessor.php +++ b/application/Espo/Tools/Notification/HookProcessor.php @@ -99,9 +99,9 @@ class HookProcessor $params = AssignmentNotificatorParams::create()->withRawOptions($options); - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $params = $params->withActionId($saveContext->getId()); } diff --git a/application/Espo/Tools/Stream/Service.php b/application/Espo/Tools/Stream/Service.php index f8bfb77b95..737c4257f1 100644 --- a/application/Espo/Tools/Stream/Service.php +++ b/application/Espo/Tools/Stream/Service.php @@ -692,9 +692,9 @@ class Service $noteOptions[SaveOption::CREATED_BY_ID] = $options[SaveOption::CREATED_BY_ID]; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); } @@ -761,9 +761,9 @@ class Service $noteOptions[SaveOption::CREATED_BY_ID] = $options[SaveOption::CREATED_BY_ID]; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); } @@ -795,9 +795,9 @@ class Service $noteOptions[SaveOption::CREATED_BY_ID] = $options[SaveOption::CREATED_BY_ID]; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); } @@ -829,9 +829,9 @@ class Service $noteOptions[SaveOption::CREATED_BY_ID] = $options[SaveOption::MODIFIED_BY_ID]; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); } @@ -867,9 +867,9 @@ class Service $noteOptions[SaveOption::CREATED_BY_ID] = $options[SaveOption::MODIFIED_BY_ID]; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); } @@ -912,9 +912,9 @@ class Service $noteOptions[SaveOption::CREATED_BY_ID] = $options[SaveOption::MODIFIED_BY_ID]; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); } @@ -1071,9 +1071,9 @@ class Service $noteOptions['createdById'] = $options['modifiedById']; } - $saveContext = $options[SaveContext::NAME] ?? null; + $saveContext = SaveContext::obtainFromRawOptions($options); - if ($saveContext instanceof SaveContext) { + if ($saveContext) { $noteOptions[SaveContext::NAME] = new SaveContext($saveContext->getId()); }