Skip to content

Commit eaf0075

Browse files
authored
feat(serializer): support filter interface on serializer filter parameter provider (#7047)
1 parent ba37b26 commit eaf0075

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Serializer/Parameter/SerializerFilterParameterProvider.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ public function provide(Parameter $parameter, array $parameters = [], array $con
3535
return null;
3636
}
3737

38-
$filter = $parameter->getFilter();
39-
if (!\is_string($filter) || !$this->filterLocator->has($filter)) {
38+
if (null === ($filter = $parameter->getFilter())) {
4039
return null;
4140
}
4241

43-
$filter = $this->filterLocator->get($filter);
42+
if (\is_string($filter) && $this->filterLocator->has($filter)) {
43+
$filter = $this->filterLocator->get($filter);
44+
}
45+
4446
if (!$filter instanceof FilterInterface) {
4547
return null;
4648
}

tests/Functional/Parameters/ParameterTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static function getResources(): array
3434
public function testWithGroupFilter(): void
3535
{
3636
$response = self::createClient()->request('GET', 'with_parameters/1?groups[]=b');
37+
$this->assertArrayNotHasKey('a', $response->toArray());
3738
$this->assertArraySubset(['b' => 'bar'], $response->toArray());
3839
$response = self::createClient()->request('GET', 'with_parameters/1?groups[]=b&groups[]=a');
3940
$this->assertArraySubset(['a' => 'foo', 'b' => 'bar'], $response->toArray());

0 commit comments

Comments
 (0)