You are here

function link_content_migrate_instance_alter in Link 7

Implements hook_migrate_instance_alter().

Widget type also changed to link_field.

File

./link.module, line 1907
Defines simple link field types.

Code

function link_content_migrate_instance_alter(&$instance_value, $field_value) {
  if ($field_value['type'] == 'link') {

    // Grab settings that were previously on the field.
    foreach (array(
      'attributes',
      'display',
      'url',
      'title',
      'title_value',
      'enable_tokens',
      'validate_url',
    ) as $setting) {
      if (isset($field_value['settings'][$setting])) {
        $instance_value['settings'][$setting] = $field_value['settings'][$setting];
      }
    }

    // Adjust widget type.
    if ($instance_value['widget']['type'] == 'link') {
      $instance_value['widget']['type'] = 'link_field';
    }

    // Adjust formatter types.
    foreach ($instance_value['display'] as $context => $settings) {
      if (in_array($settings['type'], array(
        'default',
        'title_plain',
        'url',
        'plain',
        'short',
        'label',
        'separate',
      ))) {
        $instance_value['display'][$context]['type'] = 'link_' . $settings['type'];
      }
    }
  }
}