菜谱项目

url_matcher4.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  4. use Symfony\Component\Routing\RequestContext;
  5. /**
  6. * This class has been auto-generated
  7. * by the Symfony Routing Component.
  8. */
  9. class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
  10. {
  11. public function __construct(RequestContext $context)
  12. {
  13. $this->context = $context;
  14. }
  15. public function match($pathinfo)
  16. {
  17. $allow = array();
  18. $pathinfo = rawurldecode($pathinfo);
  19. $trimmedPathinfo = rtrim($pathinfo, '/');
  20. $context = $this->context;
  21. $request = $this->request;
  22. $requestMethod = $canonicalMethod = $context->getMethod();
  23. $scheme = $context->getScheme();
  24. if ('HEAD' === $requestMethod) {
  25. $canonicalMethod = 'GET';
  26. }
  27. // just_head
  28. if ('/just_head' === $pathinfo) {
  29. if ('HEAD' !== $requestMethod) {
  30. $allow[] = 'HEAD';
  31. goto not_just_head;
  32. }
  33. return array('_route' => 'just_head');
  34. }
  35. not_just_head:
  36. // head_and_get
  37. if ('/head_and_get' === $pathinfo) {
  38. if ('GET' !== $canonicalMethod) {
  39. $allow[] = 'GET';
  40. goto not_head_and_get;
  41. }
  42. return array('_route' => 'head_and_get');
  43. }
  44. not_head_and_get:
  45. // get_and_head
  46. if ('/get_and_head' === $pathinfo) {
  47. if ('GET' !== $canonicalMethod) {
  48. $allow[] = 'GET';
  49. goto not_get_and_head;
  50. }
  51. return array('_route' => 'get_and_head');
  52. }
  53. not_get_and_head:
  54. // post_and_head
  55. if ('/post_and_get' === $pathinfo) {
  56. if (!in_array($requestMethod, array('POST', 'HEAD'))) {
  57. $allow = array_merge($allow, array('POST', 'HEAD'));
  58. goto not_post_and_head;
  59. }
  60. return array('_route' => 'post_and_head');
  61. }
  62. not_post_and_head:
  63. if (0 === strpos($pathinfo, '/put_and_post')) {
  64. // put_and_post
  65. if ('/put_and_post' === $pathinfo) {
  66. if (!in_array($requestMethod, array('PUT', 'POST'))) {
  67. $allow = array_merge($allow, array('PUT', 'POST'));
  68. goto not_put_and_post;
  69. }
  70. return array('_route' => 'put_and_post');
  71. }
  72. not_put_and_post:
  73. // put_and_get_and_head
  74. if ('/put_and_post' === $pathinfo) {
  75. if (!in_array($canonicalMethod, array('PUT', 'GET'))) {
  76. $allow = array_merge($allow, array('PUT', 'GET'));
  77. goto not_put_and_get_and_head;
  78. }
  79. return array('_route' => 'put_and_get_and_head');
  80. }
  81. not_put_and_get_and_head:
  82. }
  83. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  84. }
  85. }