id: d7_node_actu
label: Node actu
migration_group: popsu
audit: true
migration_tags:
  - Drupal 7
  - Content
  - Popsu

source:
  plugin: d7_node_actu
  batch_size: 500
  # high_water_property:
  #   name: changed
  #   alias: n

destination:
  plugin: entity:node

process:
  # nid: nid
  type:
    plugin: default_value
    default_value: actualite
  created: created
  changed: changed

  uid:
    plugin: default_value
    default_value: 34

  title: title

  field_sous_titre: field_popsu_actu_soustitre

  promote:
    plugin: default_value
    default_value: 0
    source: field_popsu_actu_enhome

  # https://understanddrupal.com/articles/migrating-dates-drupal
  # 'field_date/value':
  #   plugin: format_date
  #   source: field_popsu_actu_date
  #   from_format: 'Y-m-j H:i:s'
  #   to_format: 'Y-m-d\TH:i:s'
  # 'field_date/end_value':
  #   plugin: format_date
  #   source: field_popsu_actu_date_fin
  #   from_format: 'Y-m-j H:i:s'
  #   to_format: 'Y-m-d\TH:i:s'

  field_dates_actu:
    -
      plugin: skip_on_empty
      method: process
      source: field_date
    -
      plugin: sub_process
      # source: field_date
      process:
        value:
          # format_date was not working, converting date to timestamp on prepare_row
          plugin: format_date
          from_format: 'Y-m-d H:i:s'
          to_format: 'Y-m-d\TH:i:s'
          # \TH:i:s
          source: value
        end_value:
          plugin: format_date
          from_format: 'Y-m-d H:i:s'
          to_format: 'Y-m-d\TH:i:s'
          source: end
        # duration: duration
        timezone:
          plugin: default_value
          default_value: ""
        # settings:
        #   validate_format: false

  body:
    plugin: sub_process
    source: field_popsu_actu_body
    process:
      value: value
      summary: summary
      format:
        plugin: default_value
        default_value: wysiwyg

  field_fichier:
    plugin: sub_process
    source: field_popsu_actu_attachment
    process:
      target_id:
        plugin: migration_lookup
        migration: d7_allpublicfiles
        source: fid
        no_stub: true
      display: display
      description: description

  field_image:
    plugin: sub_process
    source: field_popsu_actu_image
    process:
      target_id:
        plugin: migration_lookup
        migration: d7_allpublicfiles
        source: fid
        no_stub: true
      alt: alt
      title: title



  field_memo: field_memo

migration_dependencies:
  required:
    - d7_allpublicfiles
