MethodNotAllowedException.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. * @api
  19. */
  20. class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
  21. {
  22. /**
  23. * @var array
  24. */
  25. protected $allowedMethods = array();
  26. public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
  27. {
  28. $this->allowedMethods = array_map('strtoupper', $allowedMethods);
  29. parent::__construct($message, $code, $previous);
  30. }
  31. /**
  32. * Gets the allowed HTTP methods.
  33. *
  34. * @return array
  35. */
  36. public function getAllowedMethods()
  37. {
  38. return $this->allowedMethods;
  39. }
  40. }