Handling Source Arrays

Last updated on
24 June 2024

All process plugins provided by Migrate Conditions are set to "handle multiples". If the source value is a scalar, then this doesn't have any effect. If the source value is an array, it means that the process plugin gets the array all at once. In most cases, this will be the most natural way to handle things. Migrate Conditions provides tools to handle a source array at more granular levels.

"foreach" Variants

If you find yourself wishing that a process plugin provided by migrate_conditions did not "handle multiples," you can use the solution introduced in v2.2.0, which exposes variants of each process plugin with handle_multiples set to false. Simply append :foreach to the process plugin name, as in if_condition:foreach.

All Elements

You can use the all_elements condition to evaluate a condition on each individual element of the source array. This condition will be true if every individual array element meets the condition.

Has Element

You can also use the has_element condition to evaluate a condition on each individual element of the source array. In contrast to all_elements, has_element will return true if at least one element in the source array meets the condition.

The has_element condition can be configured to run on a single element of the source array with a specified index/key.

Iterate with Logical Conditions

The logical conditions (and and or) can also be configured to offer special handling of an input array. By default, the conditions being AND-ed or OR-ed are evaluated on the source array. However, if the iterate configuration key is set then each of the AND-ed or OR-ed conditions is evaluated only on the element in the source array with the same index/key as the condition. Please see examples for how the iterate property is used with and and or.

Help improve this page

Page status: No known problems

You can: