Skip to content

Instantly share code, notes, and snippets.

@labboy0276
Last active March 29, 2019 01:41
Show Gist options
  • Save labboy0276/69dca7682cefe8c816ed86b6fd466520 to your computer and use it in GitHub Desktop.
Save labboy0276/69dca7682cefe8c816ed86b6fd466520 to your computer and use it in GitHub Desktop.
Various Drupal 8 Body Migration Techniques Ways
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;
/**
* Implements hook_migrate_prepare_row().
*/
function YOUR_MODULE_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
switch ($migration->id()) {
case 'config_name':
$body = $row->getSourceProperty('body');
$row->setSourceProperty('body_value', $body[0]['value']);
$row->setSourceProperty('body_summary', $body[0]['summary']);
$row->setSourceProperty('body_format', $body[0]['format']);
break;
}
}
process:
'body/value': body_value
'body/summary': body_summary
'body/format':
plugin: static_map
source: body_format
map:
full_html: full_html
filtered_html: basic_html
pure_html: full_html
plain_text: plain_text
php_code: full_html
process:
body:
plugin: sub_process
source: body
process:
value: value
summary: summary
format:
plugin: static_map
source: format
map:
full_html: full_html
filtered_html: basic_html
pure_html: full_html
plain_text: plain_text
php_code: full_html
source:
constants:
format: basic_html
process:
body/value:
plugin: extract
source: body
index:
- 0
- value
body/format: constants/format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment