You are here

function node_reference_content_migrate_instance_alter in References 7.2

Implements hook_content_migrate_instance_alter().

Use this to tweak the conversion of instance or widget settings from the D6 style to the D7 style for specific situations not handled by basic conversion, as when formatter or widget names or settings are changed.

File

node_reference/node_reference.module, line 1142
Defines a field type for referencing one node from another.

Code

function node_reference_content_migrate_instance_alter(&$instance_value, $field_value) {
  switch ($field_value['type']) {
    case 'nodereference':

      // Massage formatters.
      foreach ($instance_value['display'] as &$display) {
        switch ($display['type']) {
          case 'full':
          case 'teaser':

            // Those two formatters have been merged into
            // 'node_reference_view_mode', with a formatter setting.
            $display['type'] = 'node_reference_node';
            $display['settings']['node_reference_view_mode'] = $display['type'];
            break;
          default:

            // The formatter names changed, all are prefixed with
            // 'node_reference_'.
            $display['type'] = 'node_reference_' . $display['type'];
            break;
        }
      }

      // Massage the widget.
      switch ($instance_value['widget']['type']) {
        case 'nodereference_autocomplete':
          $instance_value['widget']['type'] = 'node_reference_autocomplete';
          $instance_value['widget']['module'] = 'node_reference';
          break;
        case 'nodereference_select':
          $instance_value['widget']['type'] = 'options_select';
          $instance_value['widget']['module'] = 'options';
          break;
        case 'nodereference_buttons':
          $instance_value['widget']['type'] = 'options_buttons';
          $instance_value['widget']['module'] = 'options';
      }
      break;
  }
}