Nessuna descrizione

MethodNotAllowedException.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Routing\Exception;
  11. /**
  12. * The resource was found but the request method is not allowed.
  13. *
  14. * This exception should trigger an HTTP 405 response in your application code.
  15. *
  16. * @author Kris Wallsmith <kris@symfony.com>
  17. */
  18. class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
  19. {
  20. protected $allowedMethods = [];
  21. /**
  22. * @param string[] $allowedMethods
  23. */
  24. public function __construct(array $allowedMethods, ?string $message = '', int $code = 0, \Throwable $previous = null)
  25. {
  26. $this->allowedMethods = array_map('strtoupper', $allowedMethods);
  27. parent::__construct($message, $code, $previous);
  28. }
  29. /**
  30. * Gets the allowed HTTP methods.
  31. *
  32. * @return string[]
  33. */
  34. public function getAllowedMethods()
  35. {
  36. return $this->allowedMethods;
  37. }
  38. }