-
Notifications
You must be signed in to change notification settings - Fork 820
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
Static lists like ArrayList
or EagerLoadedDataList
should support SearchFilter syntax for filter/exclude
#5911
Comments
To do this, you’d probably want something that provides a tester function that’s called on each object in the list So in addition to Then you could implement matches on all the current search filters. Finally, in ArrayList, you'd want to replicate the Then in the ArrayList iterator (which I’ve refactored to a generator in another PR, which will be really helpful for this) can have some code along the lines of: function getIterator() {
foreach($this->items as $record) {
if($this->recordMatchesFilters($record)) {
yield $record;
}
}
}
protected function matchesFilters($record) {
foreach($this->filters as $filter) {
if(!$this->filters->matches($record) return false;
}
return true;
} |
While you're at it, it might make sense to refactor the SearchFilter classes to have |
I created a module last year that provides this functionality: https://github.com/signify-nz/silverstripe-searchfilter-arraylist |
You definitely should @GuySartorelli. Just checked that out and I'm wondering: Can that functionality be implemented as an extension to Anyway, would be awesome to see this supported in core without the added complexity of rolling your own or having to use another module/extension that you'd have to support over the years (I mean, hell, this issue/PR has been open for nearly 6yrs! I'm feeling old). |
There aren't any extension hooks in |
We can add hooks as an enhancement as well as look into bringing that into the core, happy to review either. |
I think bringing the functionality into core would be the more beneficial of those. I don't think hooks in |
ArrayList
or EagerLoadedRelationList
should support SearchFilter syntax for filter/exclude
I've widened the scope of this issue to include the new (will be included in silverstripe/framework 5.1.0) |
ArrayList
or EagerLoadedRelationList
should support SearchFilter syntax for filter/excludeArrayList
or EagerLoadedDataList
should support SearchFilter syntax for filter/exclude
Request for enhancement to
ArrayList
originally discussed in (and subsequently taken from) core dev DL and setup as an issue here for tracking.It appears that array lists do not actually utilize filters. I was racking my brain trying to figure out why the heck this filter wouldn't work at all:
After inspecting the
->filter()
method, I noticed this core class didn't seem to handle this in the same way asDataList
. It seemed to just do a straight direct comparison... is this an oversight and, if so, should this be added into core? The consensus thus far seems to be that this enhancement would, in fact, be desirable 😄Third party library for consideration to help handle this for us (per @kinglozzer's recommendation): http://elliotswebsite.com/Pinq/ and https://github.com/TimeToogo/Pinq
Acceptance Criteria
ArrayList
supports SearchFilter syntax for itsfilter()
,filterAny()
,exclude()
, andfind()
methodsEagerLoadedDataList
supports searchfilter syntax for itsfilter()
,filterAny()
,exclude()
,excludeAny()
, andfind()
methodsSearchFilter
implementations can be usedNotes
SearchFilter
classes themselves to declare whether a record "matches" that filter.PRs
The text was updated successfully, but these errors were encountered: