function coder_upgrade_callback_node_info in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/conversions/function.inc \coder_upgrade_callback_node_info()
Updates hook_node_info() arrays.
In hook_node_info() change 'module' back to 'base' and change 'node' to 'node_content'.
@todo A similar change applies to the array passed as the parameter to node_type_set_defaults($example_node_type).
Parameters
PGPNode $node: The node of the statement containing the array object.
PGPArray $array2: The array object containing the array element ($current2).
PGPNode $current2: The node object of the array element.
string $hook: The hook name.
string $type: The type (key or value) of the array element.
string $key: The key of the array element (or the most recent key).
string $value: The value of the array element (or NULL if element is a key).
File
- coder_upgrade/
conversions/ function.inc, line 1972 - Provides conversion routines applied to functions (or hooks).
Code
function coder_upgrade_callback_node_info($node, &$array2, &$current2, $hook, $type, $key, $value) {
// DONE
cdp("inside " . __FUNCTION__);
if (!$current2 instanceof PGPNode) {
clp("ERROR: current2 is not a PGPNode object in hook_{$hook}");
return;
}
$editor = PGPEditor::getInstance();
// The keys of this array are the node type items.
if ($type == 'key' && $key == 'module') {
cdp("Found the module key");
if (!$current2->data
->isType(T_CONSTANT_ENCAPSED_STRING)) {
clp("ERROR: key expression is not a string in hook_{$hook}");
return;
}
// Change key from 'module' to 'base.'
$current2->data = $editor
->expressionToStatement("'base'");
// Find the value element for this key.
if (!$array2
->findNextValue($current2)) {
clp("ERROR: did not find a value expression for the base key in hook_{$hook}");
return;
}
if (!$current2->data
->isType(T_CONSTANT_ENCAPSED_STRING)) {
clp("ERROR: value expression is not a string in hook_{$hook}");
return;
}
if (trim($current2->data
->toString(), "'\"") == 'node') {
// Change value from 'node' to 'node_content.'
$current2->data = $editor
->expressionToStatement("'node_content'");
}
}
}