菜谱项目

MethodNotAllowedException.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 = array();
  21. public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
  22. {
  23. $this->allowedMethods = array_map('strtoupper', $allowedMethods);
  24. parent::__construct($message, $code, $previous);
  25. }
  26. /**
  27. * Gets the allowed HTTP methods.
  28. *
  29. * @return array
  30. */
  31. public function getAllowedMethods()
  32. {
  33. return $this->allowedMethods;
  34. }
  35. }