Module Description
Overview
Add logic to your process pipeline with Migrate Conditions.

This project provides a framework of condition plugins exclusively for use with the Migrate API. The module then provides a number of process plugins that can leverage the conditions.

Process plugins
* skip_on_condition
* evaluate_condition
* if_condition
* first_meeting_condition
* filter_on_condition
* switch_on_condition

This project began as an ambitious solution to #3259591: Add generic Skip migrate process plugin with various operations.

Please see the Documentation for examples and details.

Upgrading to 2.0.x branch
The 2.0.x branch uses the multiple() method more thoughtfully than in the 1.0.x branch (#3293151: Reconsider multiple method in Migrate Conditions process plugins). The 1.0.x branch is no longer supported. Minor updates to process pipelines may be required in certain cases. Please see the release notes for details.

Requirements
Core migrate module.

Recommended modules
Migrate Sandbox is an excellent way to test this stuff out. Migrate Condition plugins
There are three rough categories of condition plugins included.

"Primary" Condition Plugins These are the ones you will use the most. They do not require any other condition plugins to work.


* callback
* contains
* default
* empty
* entity_exists
* equals
* greater_than
* in_array
* in_migrate_map
* is_null
* is_stub
* isset
* less_than
* matches
* older_than

"Logical" Condition Plugins These conditions allow the primary conditions to be composed (that is, AND-ed and OR-ed)


* and
* or

"Array-Handling" Condition Plugins These conditions allow another condition to be evaluated on each element of an array.


* all_elements
* has_element

Examples
Seriously, see the Documentation for many more examples and details.

1. Skip a row is a certain source value is NOT empty. @see skip_on_condition, empty

process: skip_on_not_empty: plugin: skip_on_condition condition: plugin: empty negate: true method: (row/process) source: my_source Or negation can be done more concisely by prefixing the condition plugin id with not::

process: skip_on_not_empty: plugin: skip_on_condition condition: not:empty method: (row/process) source: my_source Since the not:empty condition does not require any further configuration, we were able to simply pass the plugin id as the condition.

Whether you negate a condition using not: or by setting negate: true is a matter of personal preference. For conditions plugins that require no additional configuration (like empty or is_null) it's much more concise to use the not: prefix.

Beginning with v2.1.0, we can alternatively specify the source directly on the condition. Thus the previous example could be written as:

process: skip_on_not_empty: plugin: skip_on_condition condition: plugin: not:empty source: my_source method: (row/process) Specifying the source on the condition is not especially useful in this case, but in other cases it may come in handy.

2. Filter old dates out of a source array of timestamps. That is, keep dates that are not older than now. @see filter_on_condition, older_than

process: future_timestamps: plugin: filter_on_condition source: source_array_of_timestamps condition: plugin: older_than negate: true format: 'U' value: now 3. Set a boolean to true if a source_age is between 13 (inclusive) and 20 (not inclusive). @see evaluate_condition, and, less_than

process: is_a_teenager: plugin: evaluate_condition source: my_source_age condition: plugin: and conditions: - plugin: not:less_than value: 13 - plugin: less_than value 20 Some conditions support parens to pass a value. The example above is written more succinctly below.

process: is_a_teenager: plugin: evaluate_condition source: my_source_age condition: plugin: and conditions: - plugin: not:less_than(13) - plugin: less_than(20) 4. Use source_value_backup if source_value is empty, This is a powerful alternative to default_value. @see if_condition, empty

process: destination_value: plugin: if_condition source: source_value condition: empty do_get: source_value_backup else_get: source_value or equivalently

process: destination_value: plugin: if_condition source: source_value condition: not:empty else_get: source_value_backup 5. Return the first source value that is not empty, like an "empty coalesce" plugin would. @see first_meeting_condition, empty

process: some_not_empty_value: plugin: first_meeting_condition condition: not:empty source: - something - another - you_get_the_idea 6. Determine whether a number is negative, positive, or zero. @see switch_on_condition, less_than, equals, default

process: sign_string: plugin: switch_on_condition source: my_source_number cases: - condition: less_than(0) default_value: negative - condition: equals(0) default_value: zero - condition: default default_value: positive The use of parens notation, shown above, can make the yaml very simple.

Project Usage
1150
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module provides a framework of condition plugins exclusively for use with the Migrate API, allowing for logic to be added to process pipelines.
Data Name
migrate_conditions

OPENAI CHATBOT

OPENAI CHATBOT

16:29:12
Generic Chatbot
Hi, I'm a Drupal module expert powered by OpenAI, answering your questions about the Drupal module ecosystem. How can I be helpful today? Please note that we will log your question.