Skip to content
Snippets Groups Projects
Commit 4816cfbc authored by Vasyl Kydyba's avatar Vasyl Kydyba
Browse files

Issue #3015199: apply patch with new message feature

parent bb59520c
No related branches found
No related tags found
1 merge request!33Issue #3015199: Allow SkipOnValue to include a message in the MigrateSkipRowException.
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment