vendor/api-platform/core/src/Symfony/EventListener/QueryParameterValidateListener.php line 41
<?php/** This file is part of the API Platform project.** (c) Kévin Dunglas <dunglas@gmail.com>** For the full copyright and license information, please view the LICENSE* file that was distributed with this source code.*/declare(strict_types=1);namespace ApiPlatform\Symfony\EventListener;use ApiPlatform\Api\QueryParameterValidator\QueryParameterValidator;use ApiPlatform\Doctrine\Orm\State\Options;use ApiPlatform\Metadata\CollectionOperationInterface;use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;use ApiPlatform\Util\OperationRequestInitiatorTrait;use ApiPlatform\Util\RequestAttributesExtractor;use ApiPlatform\Util\RequestParser;use Symfony\Component\HttpKernel\Event\RequestEvent;/*** Validates query parameters depending on filter description.** @author Julien Deniau <julien.deniau@mapado.com>*/final class QueryParameterValidateListener{use OperationRequestInitiatorTrait;public const OPERATION_ATTRIBUTE_KEY = 'query_parameter_validate';public function __construct(private readonly QueryParameterValidator $queryParameterValidator, ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null){$this->resourceMetadataCollectionFactory = $resourceMetadataCollectionFactory;}public function onKernelRequest(RequestEvent $event): void{$request = $event->getRequest();if (!$request->isMethodSafe()|| !($attributes = RequestAttributesExtractor::extractAttributes($request))|| 'GET' !== $request->getMethod()) {return;}$operation = $this->initializeOperation($request);if (!($operation?->getQueryParameterValidationEnabled() ?? true) || !$operation instanceof CollectionOperationInterface) {return;}$queryString = RequestParser::getQueryString($request);$queryParameters = $queryString ? RequestParser::parseRequestParams($queryString) : [];$class = $attributes['resource_class'];if (($options = $operation->getStateOptions()) && $options instanceof Options && $options->getEntityClass()) {$class = $options->getEntityClass();}$this->queryParameterValidator->validateFilters($class, $operation->getFilters() ?? [], $queryParameters);}}