Skip to content

Conversation

@ADmad
Copy link
Member

@ADmad ADmad commented Nov 12, 2025

This allows preserving query params for which filters are not defined and making those values available to filters (for e.g. callback filter)

@ADmad ADmad added this to the 7.next milestone Nov 12, 2025
This allows preserving query params for which filters are not defined
and making those values available to filters (for e.g. callback filter)
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an extraParams configuration option to the SearchBehavior that allows preserving query string parameters that don't have corresponding search filters defined. This enables callback filters to access values from multiple fields without requiring dummy filters for each field.

Key Changes

  • Added extraParams configuration to preserve query params without filters
  • Modified the Processor class to merge extra params into the filtered parameters
  • Updated documentation to reflect the new feature and replaced the multi-field callback workaround section

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Processor.php Added _extraParams property, setExtraParams() method, and logic to merge extra params in _extractParams()
src/Model/SearchTrait.php Added _extraParams() method returning empty array by default and integrated with processor
src/Model/Behavior/SearchBehavior.php Added extraParams config option with default empty array and override for _extraParams() method
tests/TestCase/Model/Behavior/SearchBehaviorTest.php Added test case verifying extra params are passed to callback filters alongside regular filter params
docs/additional-docs.md Added new "Extra Parameters" section documenting the feature with usage examples
docs/filters-and-examples.md Removed "Multi-field Search Callbacks" section that documented workarounds now obsoleted by extraParams feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ADmad ADmad marked this pull request as draft November 12, 2025 13:29

----------

## Multi-field Search Callbacks
Copy link
Member

Choose a reason for hiding this comment

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

IMO those are still valid strategies still for specific use cases, where those are specific to only one filter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Using an array is a valid use case, but the empty callback is surely a hack I don't want to promote once we have a proper config based solution.

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.

3 participants