You are here

media-migration-step2.yml.twig in Migrate File Entities to Media Entities 8

# This migration links the newly created media entities with entity reference field on the target bundle.

id: {{ plugin_id }}_step2
label: {{ plugin_label }} Mapping
migration_group: {{ migration_group }}
source:
  plugin: content_entity:{{ entity_type }}
  bundle: {{ source_bundle }}
  include_translations: {{ has_translation ? 'true' : 'false' }}

destination:
  plugin: entity:{{ entity_type }}
{% if has_translation %}  translations: true{% endif %}

process:
  {{ id_key }}: {{ id_key }}

  type:
    plugin: default_value
    default_value: {{ source_bundle }}
    
{% for field_name in source_field_name %}
  {{ field_name }}_media:
    plugin: file_id_lookup
    source: {{ field_name }}
    migration: {{ plugin_id }}_step1
    no_stub: true
{% endfor %}

{% if has_translation %}
  langcode: langcode
{% endif %}

migration_dependencies:
  optional:
  - {{ plugin_id }}_step1

dependencies:
  module:
    - {{ machine_name }}
  enforced:
    module:
      - {{ machine_name }}

File

src/Generators/media-migration-step2.yml.twig
View source
  1. # This migration links the newly created media entities with entity reference field on the target bundle.
  2. id: {{ plugin_id }}_step2
  3. label: {{ plugin_label }} Mapping
  4. migration_group: {{ migration_group }}
  5. source:
  6. plugin: content_entity:{{ entity_type }}
  7. bundle: {{ source_bundle }}
  8. include_translations: {{ has_translation ? 'true' : 'false' }}
  9. destination:
  10. plugin: entity:{{ entity_type }}
  11. {% if has_translation %} translations: true{% endif %}
  12. process:
  13. {{ id_key }}: {{ id_key }}
  14. type:
  15. plugin: default_value
  16. default_value: {{ source_bundle }}
  17. {% for field_name in source_field_name %}
  18. {{ field_name }}_media:
  19. plugin: file_id_lookup
  20. source: {{ field_name }}
  21. migration: {{ plugin_id }}_step1
  22. no_stub: true
  23. {% endfor %}
  24. {% if has_translation %}
  25. langcode: langcode
  26. {% endif %}
  27. migration_dependencies:
  28. optional:
  29. - {{ plugin_id }}_step1
  30. dependencies:
  31. module:
  32. - {{ machine_name }}
  33. enforced:
  34. module:
  35. - {{ machine_name }}