Migrate process plugins can declare that they will be the last plugin to execute in the pipeline. Prior to this change process plugins could throw a MigrateSkipProcessException to prevent further pipeline processing, but this forced the final value of the pipeline to be NULL. Now, a process plugin can stop the pipeline, and still return a value that can be used in the destination.
New methods
Drupal\migrate\Plugin\MigrateProcessInterface::isPipelineStopped
Determines if the pipeline should stop processing.
Drupal\migrate\Plugin\MigrateProcessInterface::resetStop
Resets the internal stop data of a plugin. Called by the executable before calling the transform method to reset data from previous runs.
\Drupal\migrate\ProcessPluginBase::stopPipeline
Helper function to stop the pipeline in ProcessPluginBase.
Process plugins can implement the new isPipelineStopped() and reset() methods. Returning TRUE from isPipelineStopped will cause the pipeline to halt further processing. reset() should reset the internal stop flag (or any other internal statuses for the process class.
In addition to implementing the new methods methods, ProcessPluginBase also includes a protected stopPipeline() method which extending classes can call to stop further processing on the pipeline.
As part of this change, the skip_on_empty plugin has been changed. It no longer throws a MigrateSkipProcessException on an empty value. It will instead stop the pipeline and return NULL.
Before
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (<some condition>) {
throw new MigrateSkipProcessException();
}
}After
protected bool $stopPipeline;
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (<some condition>) {
$this->stopPipeline = NULL;
return NULL;
}
}
public function isPipelineStopped(): bool {
return $this->stopPipeline;
}
public function reset() {
$this->stopPipeline = FALSE;
}
For process plugins extending \Drupal\migrate\ProcessPluginBase these methods are implemented in the base class along with the helper function ::stopPipeline(). If using the base class, the code becomes:
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (<some condition>) {
$this->stopPipeline();
return NULL;
}
}