Skip to content

Instantly share code, notes, and snippets.

@chriscalip
Created September 3, 2020 18:23
Show Gist options
  • Save chriscalip/605ef45a4a17d0aef5eaca49a0fe1747 to your computer and use it in GitHub Desktop.
Save chriscalip/605ef45a4a17d0aef5eaca49a0fe1747 to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\rl_migrates\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Drupal\migrate\MigrateSkipRowException;
/**
* Debug are us.
*
* @code
* process:
* field_xxx:
* plugin: rl_debug
* addSource: 1
* forceSkip: 1
* @endcode
*
* @MigrateProcessPlugin(
* id = "rl_debug",
* )
*/
class RlDebug extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$debugOutput = [];
$debugOutput[] = 'rl_debug';
$debugOutput[] = $value;
if (!empty($this->configuration['addSource'])) {
$debugOutput[] = $row->getSource();
}
drush_print_r($debugOutput);
if (!empty($this->configuration['forceSkip'])) {
throw new MigrateSkipRowException('rl_debug forceSkip');
}
return $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment