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