Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_plus
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
migrate_plus
Commits
4816cfbc
Commit
4816cfbc
authored
3 years ago
by
Vasyl Kydyba
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3015199
: apply patch with new message feature
parent
bb59520c
No related branches found
No related tags found
1 merge request
!33
Issue #3015199: Allow SkipOnValue to include a message in the MigrateSkipRowException.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/migrate/process/SkipOnValue.php
+14
-5
14 additions, 5 deletions
src/Plugin/migrate/process/SkipOnValue.php
with
14 additions
and
5 deletions
src/Plugin/migrate/process/SkipOnValue.php
+
14
−
5
View file @
4816cfbc
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment