Skip to content

Instantly share code, notes, and snippets.

@xurizaemon
Created November 6, 2018 10:12
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 xurizaemon/7b8fe27dfdd444aa90a3ac8a79f94e51 to your computer and use it in GitHub Desktop.
Save xurizaemon/7b8fe27dfdd444aa90a3ac8a79f94e51 to your computer and use it in GitHub Desktop.
transforming uid=1 to uid=3, leave the rest the same
source:
plugin: d6_node
node_type: ao
process:
title: title
uid:
plugin: transform_uid
source: node_uid
<?php
namespace Drupal\foo_migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
/**
* Replace uid=1 with uid=3
*
* @MigrateProcessPlugin(
* id = "transform_uid"
* )
*/
class TransformUid extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
return ($value == 1) ? 3 : $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment