Skip to content

Instantly share code, notes, and snippets.

@haringsrob
Created August 12, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haringsrob/d38e7a8d17ea47d4eaf7068c487d3074 to your computer and use it in GitHub Desktop.
Save haringsrob/d38e7a8d17ea47d4eaf7068c487d3074 to your computer and use it in GitHub Desktop.
Convert Drupal 7 Email field to drupal 8 Processor
<?php
namespace Drupal\base\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
/**
* This plugin converts Drupal 7 email field to drupal 8
*
* field_mail:
* plugin: email_convert
* source: field_e_mail
*
* @MigrateProcessPlugin(
* id = "email_convert"
* )
*/
class EmailConvert extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (is_array($value) && isset($value['email'])) {
return $value['email'];
}
return $value;
}
}
@haringsrob
Copy link
Author

Alternatively you can just add..

  field_new_field:
    plugin: extract
    source: field_old_field
    index:
      - email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment