405.php 737 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class Kohana_HTTP_Exception_405 extends HTTP_Exception_Expected {
  3. /**
  4. * @var integer HTTP 405 Method Not Allowed
  5. */
  6. protected $_code = 405;
  7. /**
  8. * Specifies the list of allowed HTTP methods
  9. *
  10. * @param array $methods List of allowed methods
  11. */
  12. public function allowed($methods)
  13. {
  14. if (is_array($methods))
  15. {
  16. $methods = implode(',', $methods);
  17. }
  18. $this->headers('allow', $methods);
  19. return $this;
  20. }
  21. /**
  22. * Validate this exception contains everything needed to continue.
  23. *
  24. * @throws Kohana_Exception
  25. * @return bool
  26. */
  27. public function check()
  28. {
  29. if ($this->headers('allow') === NULL)
  30. throw new Kohana_Exception('A list of allowed methods must be specified');
  31. return TRUE;
  32. }
  33. }