id: d6_field_formatter_settings
label: Field formatter configuration
migration_tags:
  - Drupal 6
  - Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: alterFieldFormatterMigration
source:
  plugin: d6_field_instance_per_view_mode
  constants:
    entity_type: node
    third_party_settings: { }

process:
  # We skip field types that don't exist because they weren't migrated by the
  # field migration.
  field_type_exists:
    -
      plugin: migration_lookup
      migration: d6_field
      source:
        - field_name
    -
      plugin: skip_on_empty
      method: row
    -
      plugin: extract
      index:
        - 1
  entity_type: 'constants/entity_type'
  bundle:
    -
      plugin: migration_lookup
      migration: d6_node_type
      source: type_name
    -
      plugin: skip_on_empty
      method: row
  view_mode:
    -
      plugin: migration_lookup
      migration: d6_view_modes
      source:
        - view_mode
    -
      plugin: skip_on_empty
      method: row
    -
      plugin: extract
      index:
        - 1
    -
      plugin: static_map
      bypass: true
      map:
        full: default
  field_name: field_name
  "options/label": label
  "options/weight": weight
  "options/type":
      -
        plugin: static_map
        bypass: true
        source:
          - type
          - 'display_settings/format'
        map:
          number_integer:
            default: number_integer
            us_0: number_integer
            be_0: number_integer
            fr_0: number_integer
            unformatted: number_unformatted
          number_float:
            default: number_decimal
            us_0: number_decimal
            us_1: number_decimal
            us_2: number_decimal
            be_0: number_decimal
            be_1: number_decimal
            be_2: number_decimal
            fr_0: number_decimal
            fr_1: number_decimal
            fr_2: number_decimal
            unformatted: number_unformatted
          number_decimal:
            default: number_decimal
            us_0: number_decimal
            us_1: number_decimal
            us_2: number_decimal
            be_0: number_decimal
            be_1: number_decimal
            be_2: number_decimal
            fr_0: number_decimal
            fr_1: number_decimal
            fr_2: number_decimal
            unformatted: number_unformatted
          email:
            default: email_mailto
            spamspan: email_mailto
            contact: email_mailto
            plain: basic_string
          fr_phone:
            default: basic_string
          be_phone:
            default: basic_string
          it_phone:
            default: basic_string
          el_phone:
            default: basic_string
          ch_phone:
            default: basic_string
          ca_phone:
            default: basic_string
          cr_phone:
            default: basic_string
          pa_phone:
            default: basic_string
          gb_phone:
            default: basic_string
          ru_phone:
            default: basic_string
          ua_phone:
            default: basic_string
          es_phone:
            default: basic_string
          au_phone:
            default: basic_string
          cs_phone:
            default: basic_string
          hu_phone:
            default: basic_string
          pl_phone:
            default: basic_string
          nl_phone:
            default: basic_string
          se_phone:
            default: basic_string
          za_phone:
            default: basic_string
          il_phone:
            default: basic_string
          nz_phone:
            default: basic_string
          br_phone:
            default: basic_string
          cl_phone:
            default: basic_string
          cn_phone:
            default: basic_string
          hk_phone:
            default: basic_string
          mo_phone:
            default: basic_string
          ph_phone:
            default: basic_string
          sg_phone:
            default: basic_string
          jo_phone:
            default: basic_string
          eg_phone:
            default: basic_string
          pk_phone:
            default: basic_string
          int_phone:
            default: basic_string
          nodereference:
            default: entity_reference_label
            plain: entity_reference_label
            full: entity_reference_entity_view
            teaser: entity_reference_entity_view
          userreference:
            default: entity_reference_label
            plain: entity_reference_label
      -
        plugin: d6_field_type_defaults
  "options/settings":
    -
      plugin: static_map
      bypass: true
      source:
        - module
        - 'display_settings/format'
      map:
        nodereference:
          default: { }
          plain:
            link: false
          full:
            view_mode: full
          teaser:
            view_mode: teaser
        userreference:
          default: { }
          plain:
            link: false
        link:
          default:
            trim_length: '80'
            url_only: 0
            url_plain: 0
            rel: 0
            target: 0
          plain:
            trim_length: '80'
            url_only: 1
            url_plain: 1
            rel: 0
            target: 0
          absolute:
            trim_length: '80'
            url_only: 1
            url_plain: 1
            rel: 0
            target: 0
          title_plain: #can't support title as plain text.
            trim_length: '80'
            url_only: 1
            url_plain: 1
            rel: 0
            target: 0
          url:
            trim_length: '80'
            url_only: 1
            url_plain: 0
            rel: 0
            target: 0
          short: #can't support hardcoded link text?
            trim_length: '80'
            url_only: 0
            url_plain: 0
            rel: 0
            target: 0
          label: # can't support label as link text?
            trim_length: '80'
            url_only: 0
            url_plain: 0
            rel: 0
            target: 0
          separate:
            trim_length: '80'
            rel: 0
            target: 0
        filefield:
          image_plain:
            image_style: ''
            image_link: ''
          image_nodelink:
            image_style: ''
            image_link: content
          image_imagelink:
            image_style: ''
            image_link: file
        date:
          default:
            format_type: fallback
            timezone_override: ''
          format_interval:
            format_type: fallback
            timezone_override: ''
          long:
            format_type: long
            timezone_override: ''
          medium:
            format_type: medium
            timezone_override: ''
          short:
            format_type: short
            timezone_override: ''
        text:
          trimmed:
            trim_length: 600
        string:
          default:
            link_to_entity: false
    -
      plugin: field_formatter_settings_defaults
  "options/third_party_settings": 'constants/third_party_settings'

destination:
  plugin: component_entity_display
migration_dependencies:
  required:
    - d6_field_instance
    - d6_view_modes
