[5.6] Add multi select element condition rule #15855
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, the
BaseElementSelectConditionRule
class only allows the selection of a single element and does not have operators and therefore does not have negative matching.This PR adds a new
BaseElementsSelectConditionRule
class that adds the functionality for selecting multiple elements and doing "is one of" and "is not one of".There is an argument to be made that this functionality could have been included in the original
BaseElementSelectConditionRule
class, but for clarity, I added this new class to showcase the code that this is needed tomake it a reality.
Like the original implementation, the new class supports being used in conditions that are stored in project config. The difference with this is that it needs to be able to handle multiple IDs. So I opted to accept a string of comma-separated IDs.
To showcase the rule's functionality I created an
EntriesConditionRule
class and added it to the Entry condition. This means on the entry index you can use the new rule. Although the first reaction might be that the rule is a little redundant, there are definitely use cases for filtering a set of data and then specifically wanting to include or exclude a certain subset of entries. The base rule will also be really helpful for Commerce to implement for some of its functionality in condition builders.