feat(doctrine): add ChainFilter to compose filters on one parameter (ORM + ODM)#8416
Open
soyuka wants to merge 2 commits into
Open
feat(doctrine): add ChainFilter to compose filters on one parameter (ORM + ODM)#8416soyuka wants to merge 2 commits into
soyuka wants to merge 2 commits into
Conversation
ChainFilter applies each wrapped filter in turn so a single query-parameter key can accept several value shapes — e.g. equality plus comparison operators — without a bespoke decorator. Each primary self-selects by value shape (ComparisonFilter ignores scalars; ExactFilter/PartialSearchFilter ignore operator-map arrays), so the composite applies all of them and merges their OpenAPI parameters. ManagerRegistry/Logger are forwarded to aware inner filters, mirroring FreeTextQueryFilter. Also adds the associative-array guard on ExactFilter/PartialSearchFilter, which is load-bearing for the chain (same guard as api-platform#8415 on 4.3; will reconcile on merge-up).
… filters Mirror the ORM ChainFilter for MongoDB ODM. Add the operator-map guard to the ODM ExactFilter and PartialSearchFilter so they self-select by value shape inside a ChainFilter — an associative operator-map array belongs to ComparisonFilter/DateFilter, not equality.
This file contains hidden or 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
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.
What
Adds
ChainFilterfor Doctrine ORM and MongoDB ODM — a thin composite that holds several filters and applies each in turn on a single query-parameter key:?birthdate=1999-12-31→ equality?birthdate[before]=…/[after]/[strictly_before]/[strictly_after]→DateFilter(full null management + date semantics), or[lt]/[gt]/… withComparisonFilterEach wrapped filter self-selects by value shape —
ComparisonFilter/DateFilterignore scalars,ExactFilter/PartialSearchFilterignore associative (operator-map) arrays — so the composite just applies all of them; nosupports()method needed.getOpenApiParameters()merges every wrapped filter's parameters.ManagerRegistry/Loggerare forwarded to aware inner filters (mirroringFreeTextQueryFilter), andChainFilter's owngetDescription()is a no-op — so wrapping a legacyDateFilteralso suppresses the cosmeticManagerRegistrywarmup ALERT from #7361.Why
Users combining equality with comparison/date operators on one property previously had to hand-write a bespoke dispatching decorator (see #8407).
ChainFiltermakes it declarative and reusable, on the "thin composers over single-responsibility primaries" line of the new filter system (likeOrFilter,FreeTextQueryFilter).Guards
Carries the associative-array guard on
ExactFilter/PartialSearchFilter(ORM and ODM):if (\is_array($value) && !array_is_list($value)) return;. It's load-bearing for the chain — without it those filters treat an operator-map as anINlist/LIKEset and corrupt the comparison. The ORM guard also ships standalone on4.3in #8415; the two reconcile cleanly on merge-up.Test
ChainFilterTest(ORM) +ChainFilterMongoDbTest(ODM): exact match,[lt],[gte], and OpenAPI merge of both filters. Both green (mongod exercised). php-cs-fixer clean, PHPStan[OK].