Skip to content

Commit 70baf7c

Browse files
committed
Changes to show payload array
1 parent 4ccc506 commit 70baf7c

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎lhc_web/modules/lhgenericbot/testpattern.php‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,22 @@
185185

186186
$patterns = [];
187187

188+
// Recursively emits {args.chat.<path>} patterns for every nested key,
189+
// so deeply nested structures (e.g. incoming_chat.payload_array) are listed.
190+
$patternWalk = function ($prefix, $value, $depth = 0) use (&$patterns, &$patternWalk) {
191+
if (is_array($value) || is_object($value)) {
192+
if ($depth > 8) {
193+
$patterns[] = '{' . $prefix . '} = ' . json_encode($value);
194+
return;
195+
}
196+
foreach ($value as $key => $val) {
197+
$patternWalk($prefix . '.' . $key, $val, $depth + 1);
198+
}
199+
} else {
200+
$patterns[] = '{' . $prefix . '} = ' . (is_bool($value) ? (int)$value : $value);
201+
}
202+
};
203+
188204
foreach ($chat->getState() as $stateKey => $stateAttr) {
189205
$patterns[] = '{args.chat.' . $stateKey .'} = ' . $stateAttr;
190206
}
@@ -193,7 +209,7 @@
193209
'online_user' => ['online_attr_system_array','online_attr_array','current_page_params','previous_chat','chat'],
194210
'department' => ['bot_configuration_array','is_overloaded','is_online'],
195211
'iwh' => ['conditions_array'],
196-
'incoming_chat' => ['incoming']
212+
'incoming_chat' => ['incoming','payload_array']
197213
];
198214

199215
foreach (['referrer_params','abnd','drpd','subject_ids','subject_ids_list','department','chat_variables_array','user','online_user',
@@ -227,9 +243,7 @@
227243
if (isset($subAttributes[$dynamicAttr])){
228244
foreach ($subAttributes[$dynamicAttr] as $subStateAttr) {
229245
if (is_array($chat?->{$dynamicAttr}?->{$subStateAttr}) || is_object($chat?->{$dynamicAttr}?->{$subStateAttr})) {
230-
foreach ($chat->{$dynamicAttr}->{$subStateAttr} as $stateSubKey => $subStateAttrVal) {
231-
$patterns[] = '{args.chat.' . $dynamicAttr .'.' . $subStateAttr . '.' . $stateSubKey . '} = ' . ((is_array($subStateAttrVal) || is_object($subStateAttrVal)) ? json_encode($subStateAttrVal) : $subStateAttrVal);
232-
}
246+
$patternWalk('args.chat.' . $dynamicAttr . '.' . $subStateAttr, $chat->{$dynamicAttr}->{$subStateAttr});
233247
}
234248
}
235249
}

0 commit comments

Comments
 (0)