MapRequestPayload.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 request content to typed object and validate it.
  17. *
  18. * @author Konstantin Myakshin <molodchick@gmail.com>
  19. */
  20. #[\Attribute(\Attribute::TARGET_PARAMETER)]
  21. class MapRequestPayload extends ValueResolver
  22. {
  23. public ArgumentMetadata $metadata;
  24. public function __construct(
  25. public readonly array|string|null $acceptFormat = null,
  26. public readonly array $serializationContext = [],
  27. public readonly string|GroupSequence|array|null $validationGroups = null,
  28. string $resolver = RequestPayloadValueResolver::class,
  29. public readonly int $validationFailedStatusCode = Response::HTTP_UNPROCESSABLE_ENTITY,
  30. ) {
  31. parent::__construct($resolver);
  32. }
  33. }