From 2e0f0fb7db73012f7e423de16fcae401951cde33 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 27 Mar 2025 14:35:01 +0200 Subject: [PATCH] ref --- .../Core/Formula/Functions/VariableGetValueByKeyType.php | 8 ++++++++ .../Core/Formula/Functions/VariableSetKeyValueType.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php b/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php index 60fe30bb5c..64c74aa7fd 100644 --- a/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php +++ b/application/Espo/Core/Formula/Functions/VariableGetValueByKeyType.php @@ -57,6 +57,14 @@ class VariableGetValueByKeyType extends BaseFunction $reference =& $this->getVariables()->$name; + return $this->getByKey($reference, $key); + } + + /** + * @throws Error + */ + private function getByKey(mixed &$reference, mixed $key): mixed + { if (!is_array($reference) && !$reference instanceof stdClass) { throw new Error("Cannot access by key of variable that is non-array and non-object."); } diff --git a/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php b/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php index 5fe8a0b7a3..50af12519a 100644 --- a/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php +++ b/application/Espo/Core/Formula/Functions/VariableSetKeyValueType.php @@ -58,6 +58,14 @@ class VariableSetKeyValueType extends BaseFunction $reference =& $this->getVariables()->$name; + $this->setByKey($reference, $key, $value); + } + + /** + * @throws Error + */ + private function setByKey(mixed &$reference, mixed $key, mixed $value): void + { if (!is_array($reference) && !$reference instanceof stdClass) { throw new Error("Cannot access by key of variable that is non-array and non-object."); }