Skip to content

Commit 8ab2d5a

Browse files
committed
Revert "Revert "test""
This reverts commit 56a893a.
1 parent 36b6df3 commit 8ab2d5a

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

src/Hydra/Serializer/CollectionFiltersNormalizer.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use ApiPlatform\Hydra\State\Util\SearchHelperTrait;
1818
use ApiPlatform\JsonLd\Serializer\HydraPrefixTrait;
1919
use ApiPlatform\Metadata\FilterInterface;
20-
use ApiPlatform\Metadata\QueryParameterInterface;
2120
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2221
use ApiPlatform\Metadata\ResourceClassResolverInterface;
2322
use ApiPlatform\State\Util\StateOptionsTrait;
@@ -108,20 +107,9 @@ public function normalize(mixed $data, ?string $format = null, array $context =
108107

109108
$resourceClass = $this->getStateOptionsClass($operation, $resourceClass);
110109

111-
$hydraPrefix = $this->getHydraPrefix($context + $this->defaultContext);
112-
['mapping' => $mapping, 'keys' => $keys] = $this->getSearchMappingAndKeys($operation, $resourceClass, $currentFilters, $parameters, [$this, 'getFilter']);
113-
114-
$hasQueryParameters = false;
115-
if ($parameters) {
116-
foreach ($parameters as $parameter) {
117-
if ($parameter instanceof QueryParameterInterface) {
118-
$hasQueryParameters = true;
119-
break;
120-
}
121-
}
122-
}
123-
124-
if ($currentFilters || $keys || $hasQueryParameters) {
110+
if ($currentFilters || ($parameters && \count($parameters))) {
111+
$hydraPrefix = $this->getHydraPrefix($context + $this->defaultContext);
112+
['mapping' => $mapping, 'keys' => $keys] = $this->getSearchMappingAndKeys($operation, $resourceClass, $currentFilters, $parameters, [$this, 'getFilter']);
125113
$normalizedData[$hydraPrefix.'search'] = [
126114
'@type' => $hydraPrefix.'IriTemplate',
127115
$hydraPrefix.'template' => \sprintf('%s{?%s}', $requestParts['path'], implode(',', $keys)),

0 commit comments

Comments
 (0)