You are here

function coder_upgrade_callback_return_case1 in Coder 7.2

Same name and namespace in other branches
  1. 7 coder_upgrade/conversions/tool.inc \coder_upgrade_callback_return_case1()

Loops on elements of first-level array.

@todo Abstract to the PGPArray object: traverse with callback. This is setting up as a nice recursive function.

Parameters

PGPArray $array1:

2 calls to coder_upgrade_callback_return_case1()
coder_upgrade_convert_return_loop_OLD in coder_upgrade/conversions/tool.inc
coder_upgrade_convert_return_OLD in coder_upgrade/conversions/tool.inc
Initiates the transformation of array assignments in a hook.

File

coder_upgrade/conversions/tool.inc, line 637
Provides tools to assist with conversion routines.

Code

function coder_upgrade_callback_return_case1(&$array1, $hook, $callback = '') {

  // DONE
  cdp("inside " . __FUNCTION__);

  // The keys of this array are the node types.
  if (!$array1 instanceof PGPArray) {
    clp("ERROR: array1 is not a PGPArray object in hook_{$hook}");
    return;
  }

  // Grab the PGPList of values.
  $values1 = $array1->values;
  $current1 = $values1
    ->first();
  while ($current1->next != NULL) {
    if ($current1->type == 'key') {
      $key1 = $current1->data;

      // Do something if appropriate.
      // This is not the one needed; we need the next level down.
    }
    elseif ($current1->type == 'value') {

      // This is the value expression for a node type key.
      $value1 = $current1->data;
      if (get_class($value1) != 'PGPExpression') {
        clp("ERROR: value1 is not a PGPExpression object in hook_{$hook}");
        return;
      }

      // This is the array of node type items.
      $array2 = $value1
        ->getElement();
      coder_upgrade_callback_return_case3($array2, $hook, $callback);
    }
    $current1 = $current1->next;
  }
}