diff --git a/src/Plugin/migrate/process/SkipOnValue.php b/src/Plugin/migrate/process/SkipOnValue.php index bf1632fefc4e23b8a17247ef2d251dff3e361426..d748ba80daed0010b0353d43bb7c45cf9342c5de 100644 --- a/src/Plugin/migrate/process/SkipOnValue.php +++ b/src/Plugin/migrate/process/SkipOnValue.php @@ -24,6 +24,9 @@ use Drupal\migrate\Row; * configuration key value. Possible values: * - row: Skips the entire row. * - process: Prevents further processing of the input property + * - message: (optional) A message to be logged in the {migrate_message_*} table + * for this row. Messages are only logged for the 'row' method. If not set, + * nothing is logged in the message table. * * @codingStandardsIgnoreStart * @@ -50,9 +53,11 @@ use Drupal\migrate\Row; * value: * - article * - testimonial + * message: 'Not an article nor a testimonial content type' * @endcode * The above example will skip processing any row for which the source row's - * content type field is not "article" or "testimonial". + * content type field is not "article" or "testimonial", and log the message 'Not + * an article nor a testimonial content type' to the message table. * * @codingStandardsIgnoreEnd */ @@ -66,6 +71,8 @@ class SkipOnValue extends ProcessPluginBase { throw new MigrateException('Skip on value plugin is missing value configuration.'); } + $message = !empty($this->configuration['message']) ? $this->configuration['message'] : ''; + if (is_array($this->configuration['value'])) { $value_in_array = FALSE; $not_equals = isset($this->configuration['not_equals']); @@ -75,11 +82,11 @@ class SkipOnValue extends ProcessPluginBase { } if (($not_equals && !$value_in_array) || (!$not_equals && $value_in_array)) { - throw new MigrateSkipRowException(); + throw new MigrateSkipRowException($message); } } elseif ($this->compareValue($value, $this->configuration['value'], !isset($this->configuration['not_equals']))) { - throw new MigrateSkipRowException(); + throw new MigrateSkipRowException($message); } return $value; @@ -93,6 +100,8 @@ class SkipOnValue extends ProcessPluginBase { throw new MigrateException('Skip on value plugin is missing value configuration.'); } + $message = !empty($this->configuration['message']) ? $this->configuration['message'] : ''; + if (is_array($this->configuration['value'])) { $value_in_array = FALSE; $not_equals = isset($this->configuration['not_equals']); @@ -102,11 +111,11 @@ class SkipOnValue extends ProcessPluginBase { } if (($not_equals && !$value_in_array) || (!$not_equals && $value_in_array)) { - throw new MigrateSkipProcessException(); + throw new MigrateSkipProcessException($message); } } elseif ($this->compareValue($value, $this->configuration['value'], !isset($this->configuration['not_equals']))) { - throw new MigrateSkipProcessException(); + throw new MigrateSkipProcessException($message); } return $value;