MapQueryString.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Attribute;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestPayloadValueResolver;
  13. use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
  14. use Symfony\Component\Validator\Constraints\GroupSequence;
  15. /**
  16. * Controller parameter tag to map the query string of the request to typed object and validate it.
  17. *
  18. * @author Konstantin Myakshin <molodchick@gmail.com>
  19. */
  20. #[\Attribute(\Attribute::TARGET_PARAMETER)]
  21. class MapQueryString extends ValueResolver
  22. {
  23. public ArgumentMetadata $metadata;
  24. /**
  25. * @param array<string, mixed> $serializationContext The serialization context to use when deserializing the query string
  26. * @param string|GroupSequence|array<string>|null $validationGroups The validation groups to use when validating the query string mapping
  27. * @param class-string $resolver The class name of the resolver to use
  28. * @param int $validationFailedStatusCode The HTTP code to return if the validation fails
  29. */
  30. public function __construct(
  31. public readonly array $serializationContext = [],
  32. public readonly string|GroupSequence|array|null $validationGroups = null,
  33. string $resolver = RequestPayloadValueResolver::class,
  34. public readonly int $validationFailedStatusCode = Response::HTTP_NOT_FOUND,
  35. ) {
  36. parent::__construct($resolver);
  37. }
  38. }