function coder_upgrade_upgrade_call_db_is_active_alter in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/conversions/call.inc \coder_upgrade_upgrade_call_db_is_active_alter()
Implements hook_upgrade_call_db_is_active_alter().
File
- coder_upgrade/
conversions/ call.inc, line 605 - Provides conversion routines applied to function calls.
Code
function coder_upgrade_upgrade_call_db_is_active_alter(&$node, &$reader) {
// Create helper objects.
$editor = PGPEditor::getInstance();
// Get the function call object.
$item =& $node->data;
// db_is_active() has been been replaced by proper exception catching.
$container =& $item->parent->container;
$parent =& $item->parent->data;
if (get_class($parent) == 'PGPConditional' && $parent->type == T_IF) {
// Build try/catch block.
$try = new PGPTryCatch();
$try->type = T_TRY;
$try->body = $parent->body;
$catch = new PGPTryCatch();
$catch->type = T_CATCH;
$catch->exception = $editor
->expressionToStatement('Exception $e');
$catch->body = new PGPBody();
$catch->body
->insertFirst($editor
->commentToStatement('// Database is unavailable.'), 'comment');
// Replace the if block with a try block.
$parent = $try;
// Insert catch block following the recast try block.
$container
->insertAfter($item->parent, $catch);
}
}