Skip to content

Instantly share code, notes, and snippets.

@kevinquillen
Created December 8, 2019 22:45
Show Gist options
  • Save kevinquillen/4c9dde4f603832e8d50ae974f4913632 to your computer and use it in GitHub Desktop.
Save kevinquillen/4c9dde4f603832e8d50ae974f4913632 to your computer and use it in GitHub Desktop.
Example redirect migration from XML source in Drupal 8.
id: redirects
label: Old article paths.
migration_group: content
source:
plugin: url
data_fetcher_plugin: http
data_parser_plugin: simple_xml
urls: http://kevinquillen.com/atom.xml
namespaces:
atom: http://www.w3.org/2005/Atom
item_selector: //atom:entry
fields:
-
name: slug
label: 'ID'
selector: atom:id
ids:
slug:
type: string
constants:
redirect_prefix: 'internal:/node/'
uid: 1
status: 301
destination:
plugin: 'entity:redirect'
process:
node:
plugin: migration_lookup
source: slug
migration: article
redirect_source:
- plugin: str_replace
source: slug
search: 'http://kevinquillen.com/'
replace: ''
redirect_redirect:
plugin: concat
source:
- constants/redirect_prefix
- "@node"
uid: constants/uid
status_code: constants/status
dependencies:
enforced:
module:
- kevinquillen_migration
migration_dependencies:
required:
- article
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment