You are here

function user_reference_content_migrate_field_alter in References 7.2

Implements hook_content_migrate_field_alter().

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

$field_value['widget_type'] is available to see what widget type was originally used.

File

user_reference/user_reference.module, line 1097
Defines a field type for referencing a user from a node.

Code

function user_reference_content_migrate_field_alter(&$field_value, $instance_value) {
  switch ($field_value['module']) {
    case 'userreference':
      $field_value['module'] = 'user_reference';
      $field_value['type'] = 'user_reference';

      // Translate 'view' settings.
      $view_name = isset($field_value['settings']['advanced_view']) ? $field_value['settings']['advanced_view'] : '';
      $view_args = isset($field_value['settings']['advanced_view_args']) ? $field_value['settings']['advanced_view_args'] : '';
      $view_args = array_map('trim', explode(',', $view_args));
      $field_value['settings']['view'] = array(
        'view_name' => $view_name,
        'display_name' => 'default',
        'args' => $view_args,
      );
      if ($view_name) {
        $field_value['messages'][] = t("The field uses the view @view_name to determine referenceable users. You will need to manually edit the view and add a display of type 'References'.", array(
          '@view_name' => $view_name,
        ));
      }
      unset($field_value['settings']['advanced_view']);
      unset($field_value['settings']['advanced_view_args']);
      break;
  }
}