Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Add multi select element condition rule #15855

Open
wants to merge 5 commits into
base: 5.6
Choose a base branch
from

Conversation

nfourtythree
Copy link
Contributor

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 to
make 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.

@brandonkelly brandonkelly changed the base branch from 5.5 to 5.6 November 15, 2024 16:09
@nfourtythree nfourtythree changed the title [5.5] Add multi select element condition rule [5.6] Add multi select element condition rule Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant