Process plugin: get

Last updated on
13 October 2016

Typically, the get plugin is the start of every process pipeline, typically shorthanded by adding a source key to another plugin.

It has a single configuration key, the source. The value typically is a source property and after running this plugin, the pipeline value will be set to the value of that property. Ie:

process:
  bar:
    plugin: get
    source: foo

will simply copy the source value of foo to the destination property bar. Since get is the default process plugin, it can be shorthanded as such:

process:
  bar: foo

get also supports a list of source properties. If this list contains an empty element then the current value will be used. This makes it impossible to reach a source property with an empty string as its name.

get also supports copying destination values. These are indicated by a starting @ sign. Values using @ must be wrapped in quotes.

process:
  foo:
    plugin: machine_name
    source: baz
  bar:
    plugin: get
    source: '@foo'

This will simply copy the destination value of foo to the destination property bar. foo configuration is included for illustration purposes.

Because of this, if your source or destination property actually starts with a @ you need to double those starting characters up. This means that if a destination property happens to start with a @ and you want to refer it, you'll need to start with three @ characters -- one to indicate the destination and two for escaping the real @.

process:
  @foo:
    plugin: machine_name
    source: baz
  bar:
    plugin: get
    source: '@@@foo'

This should occur extremely rarely.

This plugin is implemented at file :
core/modules/migrate/src/Plugin/migrate/process/Get.php