You are here

function coder_upgrade_upgrade_hook_alter in Coder 7.2

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

Implements hook_upgrade_hook_alter().

File

coder_upgrade/conversions/function.inc, line 93
Provides conversion routines applied to functions (or hooks).

Code

function coder_upgrade_upgrade_hook_alter(&$node, &$reader, $hook) {
  cdp("inside " . __FUNCTION__);
  $item =& $node->data;
  $editor = PGPEditor::getInstance();

  // Changes: implementation_hook_comment
  if ($item->comment) {

    // Update document comment for hook implementations.
    $item->comment = preg_replace('@\\*\\s+[iI]mplement.*?(hook_.*?)(\\(\\)|)(\\.|)$@m', "* Implements \$1().", $item->comment);
  }
  else {

    // Add a document comment.
    $item->comment = $editor
      ->commentToStatement("/**\n * @todo Please document this function.\n * @see http://drupal.org/node/1354\n */");
  }
  global $_coder_upgrade_menu_registry, $_coder_upgrade_theme_registry;
  cdp($node->data->name);
  if (in_array($node->data->name, $_coder_upgrade_menu_registry)) {

    // http://drupal.org/node/224333#hook_forms_signature
    coder_upgrade_convert_form_callback($node);
  }
  elseif (strpos($node->data->name, 'theme_') === 0) {
    $theme_name = substr($node->data->name, strpos($node->data->name, "theme_") + 6);
    if (isset($_coder_upgrade_theme_registry[$theme_name])) {

      // http://drupal.org/node/224333#drupal_render_children
      // http://drupal.org/node/224333#theme_changes
      coder_upgrade_convert_theme_callback($node);
    }
    else {
      $msg = 'TODO: Should this theme ' . $theme_name . ' be declared in hook_theme()?';
      clp($msg);
      $node->data->body
        ->insertFirst($editor
        ->commentToStatement($msg));
    }
  }
}