MapDateTime.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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\HttpKernel\Controller\ArgumentResolver\DateTimeValueResolver;
  12. use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
  13. /**
  14. * Controller parameter tag to configure DateTime arguments.
  15. */
  16. #[\Attribute(\Attribute::TARGET_PARAMETER)]
  17. class MapDateTime extends ValueResolver
  18. {
  19. /**
  20. * @param string|null $format The DateTime format to use, @see https://php.net/datetime.format
  21. * @param bool $disabled Whether this value resolver is disabled; this allows to enable a value resolver globally while disabling it in specific cases
  22. * @param class-string<ValueResolverInterface>|string $resolver The name of the resolver to use
  23. */
  24. public function __construct(
  25. public readonly ?string $format = null,
  26. bool $disabled = false,
  27. string $resolver = DateTimeValueResolver::class,
  28. ) {
  29. parent::__construct($resolver, $disabled);
  30. }
  31. }