migrate_plus.migration.beer_term.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # A "migration" is, in technical terms, a plugin whose configuration describes
  2. # how to read source data, process it (generally by mapping source fields to
  3. # destination fields), and write it to Drupal.
  4. # The machine name for a migration, used to uniquely identify it.
  5. id: beer_term
  6. # A human-friendly description of the migration.
  7. label: Migrate style categories from the source database to taxonomy terms
  8. # The machine name of the group containing this migration (which contains shared
  9. # configuration to be merged with our own configuration here).
  10. migration_group: beer
  11. # Every migration must have a source plugin, which controls the delivery of our
  12. # source data. In this case, our source plugin has the name "beer_term", which
  13. # Drupal resolves to the PHP class defined in
  14. # src/Plugin/migrate/source/BeerTerm.php.
  15. source:
  16. plugin: beer_term
  17. # Every migration must also have a destination plugin, which handles writing
  18. # the migrated data in the appropriate form for that particular kind of data.
  19. # Most Drupal content is an "entity" of one type or another, and we need to
  20. # specify what entity type we are populating (in this case, taxonomy terms).
  21. # Unlike the source plugin (which is specific to our particular scenario), this
  22. # destination plugin is implemented in Drupal itself.
  23. destination:
  24. plugin: entity:taxonomy_term
  25. # Here's the meat of the migration - the processing pipeline. This describes how
  26. # each destination field is to be populated based on the source data. For each
  27. # destination field, one or more process plugins may be invoked.
  28. process:
  29. # The simplest process plugin is named 'get' - it is the default plugin, so
  30. # does not need to be explicitly named. It simply copies the source value
  31. # (the 'style' field from the source database in this case) to the destination
  32. # field (the taxonomy term 'name' field). You can see we simply copy the
  33. # source 'details' field to destination 'description' field in the same way.
  34. name: style
  35. description: details
  36. # Here is a new plugin - default_value. In its simplest usage here, it is used
  37. # to hard-code a destination value, the vid (vocabulary ID) our taxonomy terms
  38. # should be assigned to. It's important to note that while above the right
  39. # side of the mappings was a source field name, here the right side of the
  40. # 'default_value:' line is an actual value.
  41. vid:
  42. plugin: default_value
  43. default_value: migrate_example_beer_styles
  44. # Here's another new plugin - migration. When importing data from another
  45. # system, typically the unique identifiers for items on the destination side
  46. # are not the same as the identifiers were on the source side. For example, in
  47. # our style data the term names are the unique identifiers for each term,
  48. # while in Drupal each term is assigned a unique integer term ID (tid). When
  49. # any such items are referenced in Drupal, the reference needs to be
  50. # translated from the old ID ('ale') to the new ID (1). The migration
  51. # framework keeps track of the relationships between source and destination
  52. # IDs in map tables, and the migration plugin is the means of performing a
  53. # lookup in those map tables during processing.
  54. parent:
  55. plugin: migration
  56. # Here we reference the migration whose map table we're performing a lookup
  57. # against. You'll note that in this case we're actually referencing this
  58. # migration itself, since category parents are imported by the same
  59. # migration. This works best when we're sure the parents are imported
  60. # before the children, and in this case our source plugin is guaranteeing
  61. # that.
  62. migration: beer_term
  63. # 'style_parent' is the parent reference field from the source data. The
  64. # result of this plugin is that the destination 'parent' field is populated
  65. # with the Drupal term ID of the referenced style (or NULL if style_parent
  66. # was empty).
  67. source: style_parent
  68. # We'll learn more about dependencies in beer_node - here, we leave them empty.
  69. migration_dependencies: {}
  70. # By default, configuration entities (like this migration) are not automatically
  71. # removed when the migration which installed them is uninstalled. To have your
  72. # migrations uninstalled with your migration module, add an enforced dependency
  73. # on your module.
  74. dependencies:
  75. enforced:
  76. module:
  77. - migrate_example