id: d7_field_formatter_settings
label: Field formatter configuration
migration_tags:
  - Drupal 7
  - Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: alterFieldFormatterMigration
source:
  plugin: d7_field_instance_per_view_mode
  constants:
    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: d7_field
      source:
        - field_name
        - entity_type
    -
      plugin: extract
      index:
        - 0
    -
      plugin: skip_on_empty
      method: row
  entity_type: entity_type
  # The bundle needs to be statically mapped in order to support comment types
  # that might already exist before this migration is run. See
  # d7_comment_type.yml or more information.
  bundle:
    plugin: static_map
    source: bundle
    bypass: true
    map:
      comment_node_forum: comment_forum
  view_mode:
    -
      plugin: migration_lookup
      migration: d7_view_modes
      source:
        - entity_type
        - view_mode
    -
      plugin: extract
      index:
        - 1
    -
      plugin: static_map
      bypass: true
      map:
        full: default
  field_name: field_name
  "options/label": 'formatter/label'
  "options/weight": 'formatter/weight'
  # The field plugin ID.
  plugin_id:
    plugin: process_field
    source: type
    method: getPluginId
  # The formatter to use.
  formatter_type:
    plugin: process_field
    source: type
    method: getFieldFormatterType
  "options/type":
    -
      plugin: static_map
      bypass: true
      source:
        - '@plugin_id'
        - '@formatter_type'
      # The map is generated by the getFieldFormatterMap() method from the
      # migrate field plugins.
      map: []
    -
      plugin: d7_field_type_defaults
    -
      plugin: skip_on_empty
      method: row
  hidden:
    plugin: static_map
    source: "@options/type"
    map:
      hidden: true
    default_value: false
  "options/settings":
    plugin: default_value
    source: 'formatter/settings'
    default_value: []
  "options/third_party_settings": 'constants/third_party_settings'
destination:
  plugin: component_entity_display
migration_dependencies:
  required:
    - d7_field_instance
    - d7_view_modes
