Migrate API
Article
The migrate API works with plugins and stores the configuration for those plugins in a configuration entity. There are a number of plugin types offered: source, process, and destination are the most important. Source merely provides an iterator and identifiers, and most of the time the destination plugins provided by core are adequate, so this article will focus on process plugins.
Process plugins
Nothing gets into the destination unless it is specified under the top level process
key in the configuration entity. Each key under process
is a destination property and the value of it is a process pipeline. Each “stage” of this pipeline is a plugin which receives the output of the previous stage as input, does some transformation on it, and produces the new value of the pipeline.
There are a few plugins which indeed only use the pipeline value as input – for example, the machine name plugin transliterates the input (presumably a human name) and replaces non-alphanumeric characters with underscores. However, if that was all plugins could do they wouldn’t be too useful. Instead, every plugin receives the whole row and the name of the destination property currently being created.
Each stage in the process pipeline is described by an array, where the plugin
key is mandatory and the rest is just the plugin configuration. For example:
process:
vid:
-
plugin: machine_name
source: name
-
plugin: dedupe_entity
entity_type: taxonomy_vocabulary
field: vid
The above mentioned machine name transformation is run on name
and then the entity deduplication plugin adds a numeric postfix ensuring the vid field of the taxonomy_vocabulary
entity is unique. That is the canonical format of the process pipeline.