function coder_upgrade_upgrade_call_file_set_status_alter in Coder 7.2
Same name and namespace in other branches
- 7 coder_upgrade/conversions/call.inc \coder_upgrade_upgrade_call_file_set_status_alter()
Implements hook_upgrade_call_file_set_status_alter().
File
- coder_upgrade/
conversions/ call.inc, line 1622 - Provides conversion routines applied to function calls.
Code
function coder_upgrade_upgrade_call_file_set_status_alter(&$node, &$reader) {
// DONE
// Create helper objects.
$editor = PGPEditor::getInstance();
// Get the function call object.
$item =& $node->data;
// Get the text of the function call and its parent statement.
$temp1 = $item
->toString();
$temp2 = $editor
->statementsToText($item->parent);
// This includes a ';' at end.
if ($item->parameters
->count() == 2) {
$p0 = $item
->printParameter(0);
$p1 = $item
->printParameter(1);
// Insert statement.
$statement = $editor
->textToStatements("{$p0}->status &= {$p1}")
->getElement(0);
$item
->insertStatementBefore($statement);
// Change statement.
$from = $temp1;
$to = "{$p0} = file_save({$p0})";
$temp = str_replace($from, $to, $temp2);
$temp = $editor
->textToStatements($temp);
$parent = $item->parent;
$parent->data = $temp
->getElement(0);
}
}