function coder_upgrade_callback_return_case3 in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/conversions/tool.inc \coder_upgrade_callback_return_case3()
Loops on elements of second-level array.
@todo Abstract to the PGPArray object: traverse with callback.
Parameters
PGPArray $array2:
3 calls to coder_upgrade_callback_return_case3()
- coder_upgrade_callback_return_case1 in coder_upgrade/
conversions/ tool.inc - Loops on elements of first-level array.
- coder_upgrade_callback_return_case5 in coder_upgrade/
conversions/ tool.inc - coder_upgrade_convert_return_loop_OLD in coder_upgrade/
conversions/ tool.inc
File
- coder_upgrade/
conversions/ tool.inc, line 678 - Provides tools to assist with conversion routines.
Code
function coder_upgrade_callback_return_case3(&$array2, $hook, $callback = '') {
// DONE
cdp("inside " . __FUNCTION__);
$callback = $callback == '' ? "coder_upgrade_callback_{$hook}" : $callback;
// The keys of this array are the node type items.
if (!$array2 instanceof PGPArray) {
clp("ERROR: array2 is not a PGPArray object in hook_{$hook}");
cdp("ERROR: array2 is not a PGPArray object in hook_{$hook}");
cdp($array2);
return;
}
// Grab the PGPList of values.
$values2 = $array2->values;
$key2 = '';
$current2 = $values2
->first();
while ($current2->next != NULL) {
if ($current2->type == 'key') {
$key2 = trim($current2->data
->toString(), "'\"");
$callback($array2, $current2, $hook, $current2->type, $key2, NULL);
}
elseif ($current2->type == 'value') {
$value2 = trim($current2->data
->toString(), "'\"");
$callback($array2, $current2, $hook, $current2->type, $key2, $value2);
$key2 = '';
// Clear key in case not all elements have keys.
}
$current2 = $current2->next;
}
}