|
| 1 | +# The machine name for a migration. Also used by various CLI tools when |
| 2 | +# referencing the migration as an argument for a command. |
| 3 | +id: baseball_player |
| 4 | + |
| 5 | +# A human-friendly description of the migration. This is used by varous UI and |
| 6 | +# CLI tools when showing a list of available migrations. |
| 7 | +label: Migrate list of players |
| 8 | + |
| 9 | +# Optional group for the migration. This is a feature provided by the |
| 10 | +# migrate_plus module and allows for running an entire group of migrations |
| 11 | +# together. |
| 12 | +migration_group: baseball |
| 13 | + |
| 14 | +# Every migration must have a source plugin. Set this to the ID of the plugin to |
| 15 | +# use. |
| 16 | +# |
| 17 | +# For our custom migration this should be the source plugin we wrote. |
| 18 | +# \Drupal\baseball_migration\Plugin\migrate\source\BaseballPlayer The value here is |
| 19 | +# the ID value from the source plugin's annotation. |
| 20 | +source: |
| 21 | + plugin: baseball_player |
| 22 | + |
| 23 | +# Every migration must also have a destination plugin, which handles writing |
| 24 | +# the migrated data in the appropriate form for that particular kind of data. |
| 25 | +# This value should be the ID of the destination plugin to use. |
| 26 | +destination: |
| 27 | + plugin: entity:node |
| 28 | + |
| 29 | +# Here's the meat of the migration - the processing pipeline. This describes how |
| 30 | +# each destination field is to be populated based on the source data. For each |
| 31 | +# destination field, one or more process plugins may be invoked. |
| 32 | +process: |
| 33 | + # Hardcode the destination node type (bundle) as 'player' using the |
| 34 | + # 'default_value' process plugin. |
| 35 | + type: |
| 36 | + plugin: default_value |
| 37 | + default_value: player |
| 38 | + |
| 39 | + # Simple field mappings that require no extra processing can use the default |
| 40 | + # 'get' process plugin. This just copies the value from the source to the |
| 41 | + # destination. 'get' is the default when no plugin is defined, so you can just |
| 42 | + # do destination_field: source_field. |
| 43 | + # |
| 44 | + # Our player content type in Drupal has a field named, 'field_player_weight' |
| 45 | + # and our Source plugin defines a 'weight' field in it's ::getFields() method. |
| 46 | + # The destination field (or property) name goes on the left and the source |
| 47 | + # field goes on the right. |
| 48 | + field_player_weight: weight |
| 49 | + field_player_height: height |
| 50 | + field_player_bats: bats |
| 51 | + field_player_throws: throws |
| 52 | + field_player_given_name: nameGiven |
| 53 | + |
| 54 | + # We generate the node.title (which we treat as the name) by concatnating |
| 55 | + # two soure fields together and putting a space between them using the |
| 56 | + # 'concat' process plugin. |
| 57 | + title: |
| 58 | + plugin: concat |
| 59 | + source: |
| 60 | + - nameFirst |
| 61 | + - nameLast |
| 62 | + delimiter: " " |
| 63 | + |
| 64 | + # Same thing with the birthday, concat these fields together using the |
| 65 | + # 'concat' process plugin. |
| 66 | + field_player_birth: |
| 67 | + plugin: concat |
| 68 | + source: |
| 69 | + - birthMonth |
| 70 | + - birthDay |
| 71 | + - birthYear |
| 72 | + delimiter: / |
| 73 | + |
| 74 | + # For death day we need to provide a default value in the case where the |
| 75 | + # player hasn't died yet. Also provides an example of using multiple process |
| 76 | + # plugins together. In this case we first use the 'concat' plugin to combine |
| 77 | + # three fields from the source data, and then use the 'default_value' plugin |
| 78 | + # to provide a default value for the field in the case that the previous step |
| 79 | + # resulted in an empty value. |
| 80 | + field_player_death: |
| 81 | + - |
| 82 | + plugin: concat |
| 83 | + source: |
| 84 | + - deathMonth |
| 85 | + - deathDay |
| 86 | + - deathYear |
| 87 | + delimiter: / |
| 88 | + - |
| 89 | + plugin: default_value |
| 90 | + default_value: "" |
| 91 | + |
| 92 | +# Declare optional dependencies for a migration. This one has none. |
| 93 | +migration_dependencies: {} |
0 commit comments