-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
[spiral/filters] Filters improvements #961
Merged
butschster
merged 13 commits into
spiral:master
from
msmakouz:feature/filters-improvement
Aug 14, 2023
Merged
[spiral/filters] Filters improvements #961
butschster
merged 13 commits into
spiral:master
from
msmakouz:feature/filters-improvement
Aug 14, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
butschster
changed the title
[spiral/filters] Filters improvements, draft
[spiral/filters] Filters improvements
Aug 10, 2023
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #961 +/- ##
============================================
+ Coverage 83.83% 83.87% +0.03%
- Complexity 5988 6025 +37
============================================
Files 786 792 +6
Lines 16898 16971 +73
============================================
+ Hits 14167 14234 +67
- Misses 2731 2737 +6
☔ View full report in Codecov by Sentry. |
butschster
approved these changes
Aug 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Features
1. Value casters for Filter properties
Introducing Spiral\Filters\Model\Mapper\Mapper that sets values for filter properties. It utilizes a collection of casters, each designed to handle a specific type of value. Default casters include:
Casters are extensible and can be created and added by users within the application. To achieve this, it's necessary to create a custom caster object, implement the
Spiral\Filters\Model\Mapper\CasterInterface
interface, and implements the supports and setValue methods. The supports method takes the property type as a parameter and must determine whether the caster can assign a value. The setValue method is called if the supports method returns true. It takes the Filter, property, and value as parameters and is responsible for setting the value in the Filter property. And register custom caster in theSpiral\Filters\Model\Mapper\CasterRegistryInterface
via register method.Closes: #957
Bugfixes
1. Fixed nullable Nested Filters
Suppose there was a nested nullable filter within the main filter, along with validation rules:
We send only the name and get an error:
Without validation rules, we get a filter object with uninitialized properties.
After these changes, in these cases the address property will be
null
.Closes: #910