You are here

function coder_upgrade_upgrade_hook_profile_alter_alter in Coder 7

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

Implements hook_upgrade_hook_profile_alter_alter().

File

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

Code

function coder_upgrade_upgrade_hook_profile_alter_alter(&$node, &$reader) {

  // Changes: hook-user-changes
  $item =& $node->data;
  $body =& $item->body;

  // Create helper objects.
  $editor = PGPEditor::getInstance();
  global $_coder_upgrade_module_name;

  // Rename function.
  $item->name = $_coder_upgrade_module_name . '_user_view';

  // Update document comment.
  $item->comment['value'] = preg_replace('@hook_profile_alter([^i])@', "hook_user_view\$1", $item->comment['value']);

  // Remove '&' from first parameter.
  //   $p0 = str_replace('&', '', $item->getParameter()->stripComments()->toString());
  // Save the name of first parameter.
  if ($p0 = $item
    ->getParameterVariable()) {

    // The parameter includes a variable; save the variable.
    // Remove '&' from first parameter.
    $p0 = str_replace('&', '', $p0
      ->toString());
  }
  else {

    // The parameter has no variable.
    $p0 = '$xx_missing_xx';
    $body
      ->insertFirst($editor
      ->commentToStatement('// TODO: Name the variable ' . $p0 . ' which was missing in the old function signature.'));
  }

  // Add $view_mode parameter.
  $editor
    ->setParameters($item, array(
    $p0,
    '$view_mode',
  ));
}