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

Add example for combining #293

Merged
merged 1 commit into from
Oct 1, 2021
Merged

Add example for combining #293

merged 1 commit into from
Oct 1, 2021

Conversation

dereuromark
Copy link
Member

also fixed header

I found this out when trying to set a custom one but it still used the "inherited" one.

'collectionClass' => PostsFilterCollection::class,
]);
```
This would add additional filters on top of inherited `status` one.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically the ones you add in searchManager() are the additional ones that are added to the ones in PostsFilterCollection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, as it still overwrote the ones in the filter for me.
I will have to test that once more.
Maybe it appends it and PHP just uses the last config in array found by key ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah using the same name will override, so if PostsFilterCollection already had a filter with name status it will be overwritten through searchManager().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which in the end means what I wrote though ;) Even if the technical detail might be a bit different.

Copy link
Member Author

@dereuromark dereuromark Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should fix the code here to first use the generic ones, then add the custom ones (overwriting).
If you configure a custom collection one would expect those to take precedence IMO.
Rare case, sure. Thus we can probably easily fix this in a minor release.

Copy link
Member

@ADmad ADmad Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no merging of filters/collections done anywhere. The use of collectionClass decides which collection class is instantiated and used for the name "default". By default search manager creates a FilterCollection instance which doesn't have have filters preset if no collectionClass config is specified.

Copy link
Member Author

@dereuromark dereuromark Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to rephrase this PR if needed, then we can probably merge and close.
I guess I don't want to deep dive too much into this - even if there was some value for me.
I just then go either full class or full table for mine for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just then go either full class or full table for mine for now.

That's the best approach. I personally would never specify collectionClass and use searchManager() too to modify the collection instance. That's why I don't want to document this and put ideas into people's minds 🙂.

Just the use of collectionClass is already documented.

Copy link
Member Author

@dereuromark dereuromark Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is important to mention the side effects of them used together

In my upgraded apps I have tons of Table ones still
And in some cases I now added custom ones on top, and the intuitive expectation is for those to take full precedence or overwrite. While keeping the behavior for the other actions (admin prefix and otherwise) that have no such custom ones added at runtime yet.

now when you search in those you have weird effects that you cannot explain (and are silent, since it doesn't throw errors or warnings).

Copy link
Member

@ADmad ADmad Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is important to mention the side effects of them used together

Sounds fair, I'll think of a suitable note.

@dereuromark
Copy link
Member Author

Did you have a change to follow up on this?
Or shall we merge this as helpful note on the combination?

also note the header type change that is part of it.

@ADmad ADmad merged commit 5d95759 into master Oct 1, 2021
@ADmad ADmad deleted the dereuromark-patch-1 branch October 1, 2021 12:54
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.

2 participants