diff --git a/src/Elasticsearch/Filter/AbstractSearchFilter.php b/src/Elasticsearch/Filter/AbstractSearchFilter.php index 2a4a4e4410..8c36d724a7 100644 --- a/src/Elasticsearch/Filter/AbstractSearchFilter.php +++ b/src/Elasticsearch/Filter/AbstractSearchFilter.php @@ -96,6 +96,7 @@ public function getDescription(string $resourceClass): array 'property' => $property, 'type' => $hasAssociation ? 'string' : $this->getPhpType($type), 'required' => false, + 'is_collection' => str_ends_with((string) $filterParameterName, '[]'), ]; } } diff --git a/tests/Elasticsearch/Filter/MatchFilterTest.php b/tests/Elasticsearch/Filter/MatchFilterTest.php index a234170e5d..d042392ee8 100644 --- a/tests/Elasticsearch/Filter/MatchFilterTest.php +++ b/tests/Elasticsearch/Filter/MatchFilterTest.php @@ -176,41 +176,49 @@ public function testGetDescription(): void 'property' => 'id', 'type' => 'int', 'required' => false, + 'is_collection' => false, ], 'id[]' => [ 'property' => 'id', 'type' => 'int', 'required' => false, + 'is_collection' => true, ], 'name' => [ 'property' => 'name', 'type' => 'string', 'required' => false, + 'is_collection' => false, ], 'name[]' => [ 'property' => 'name', 'type' => 'string', 'required' => false, + 'is_collection' => true, ], 'date' => [ 'property' => 'date', 'type' => \DateTimeInterface::class, 'required' => false, + 'is_collection' => false, ], 'date[]' => [ 'property' => 'date', 'type' => \DateTimeInterface::class, 'required' => false, + 'is_collection' => true, ], 'weird' => [ 'property' => 'weird', 'type' => 'string', 'required' => false, + 'is_collection' => false, ], 'weird[]' => [ 'property' => 'weird', 'type' => 'string', 'required' => false, + 'is_collection' => true, ], ], $matchFilter->getDescription(Foo::class) diff --git a/tests/Elasticsearch/Filter/TermFilterTest.php b/tests/Elasticsearch/Filter/TermFilterTest.php index c28c8517a2..1f7c8ca573 100644 --- a/tests/Elasticsearch/Filter/TermFilterTest.php +++ b/tests/Elasticsearch/Filter/TermFilterTest.php @@ -176,41 +176,49 @@ public function testGetDescription(): void 'property' => 'id', 'type' => 'int', 'required' => false, + 'is_collection' => false, ], 'id[]' => [ 'property' => 'id', 'type' => 'int', 'required' => false, + 'is_collection' => true, ], 'name' => [ 'property' => 'name', 'type' => 'string', 'required' => false, + 'is_collection' => false, ], 'name[]' => [ 'property' => 'name', 'type' => 'string', 'required' => false, + 'is_collection' => true, ], 'date' => [ 'property' => 'date', 'type' => \DateTimeInterface::class, 'required' => false, + 'is_collection' => false, ], 'date[]' => [ 'property' => 'date', 'type' => \DateTimeInterface::class, 'required' => false, + 'is_collection' => true, ], 'weird' => [ 'property' => 'weird', 'type' => 'string', 'required' => false, + 'is_collection' => false, ], 'weird[]' => [ 'property' => 'weird', 'type' => 'string', 'required' => false, + 'is_collection' => true, ], ], $termFilter->getDescription(Foo::class)