Create a "pipeline" process plugin to re-use YAML config
Issue #3123534 on drupal.org by herved.
Problem/Motivation
We often need to copy/paste YAML config across several migrations.
If we want to apply a specific suite of process plugins to all fulltext fields (e.g: dom process plugins), all you can do ATM is copy/paste the suite of yaml config everywhere.
Same if you have a specific process plugin with specific/complex config.
Proposed resolution
Define a "pipeline" process plugin that defines a suite of process plugins to run.
Given the following example in a migration:
process:
'body/value':
- plugin: pipeline
id: my_process_pipeline
source: 'body/0/value'
We would create the file migrate_plus.migration_process_pipeline.my_process_pipeline.yml with config:
langcode: en
status: true
id: my_process_pipeline
label: 'My process pipeline'
description: 'Process pipeline for processing fulltext fields'
process:
-
plugin: dom
method: import
-
plugin: dom_str_replace
mode: attribute
xpath: '//a'
attribute_options:
name: href
search: 'foo'
replace: 'bar'
-
plugin: dom_str_replace
mode: attribute
xpath: '//a'
attribute_options:
name: href
regex: true
search: '/foo/'
replace: 'bar'
-
plugin: dom
method: export