url_matcher4.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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($rawPathinfo)
  16. {
  17. $allow = [];
  18. $pathinfo = rawurldecode($rawPathinfo);
  19. $trimmedPathinfo = rtrim($pathinfo, '/');
  20. $context = $this->context;
  21. $request = $this->request ?: $this->createRequest($pathinfo);
  22. $requestMethod = $canonicalMethod = $context->getMethod();
  23. if ('HEAD' === $requestMethod) {
  24. $canonicalMethod = 'GET';
  25. }
  26. // just_head
  27. if ('/just_head' === $pathinfo) {
  28. $ret = ['_route' => 'just_head'];
  29. if (!in_array($requestMethod, ['HEAD'])) {
  30. $allow = array_merge($allow, ['HEAD']);
  31. goto not_just_head;
  32. }
  33. return $ret;
  34. }
  35. not_just_head:
  36. // head_and_get
  37. if ('/head_and_get' === $pathinfo) {
  38. $ret = ['_route' => 'head_and_get'];
  39. if (!in_array($canonicalMethod, ['HEAD', 'GET'])) {
  40. $allow = array_merge($allow, ['HEAD', 'GET']);
  41. goto not_head_and_get;
  42. }
  43. return $ret;
  44. }
  45. not_head_and_get:
  46. // get_and_head
  47. if ('/get_and_head' === $pathinfo) {
  48. $ret = ['_route' => 'get_and_head'];
  49. if (!in_array($canonicalMethod, ['GET', 'HEAD'])) {
  50. $allow = array_merge($allow, ['GET', 'HEAD']);
  51. goto not_get_and_head;
  52. }
  53. return $ret;
  54. }
  55. not_get_and_head:
  56. // post_and_head
  57. if ('/post_and_head' === $pathinfo) {
  58. $ret = ['_route' => 'post_and_head'];
  59. if (!in_array($requestMethod, ['POST', 'HEAD'])) {
  60. $allow = array_merge($allow, ['POST', 'HEAD']);
  61. goto not_post_and_head;
  62. }
  63. return $ret;
  64. }
  65. not_post_and_head:
  66. if (0 === strpos($pathinfo, '/put_and_post')) {
  67. // put_and_post
  68. if ('/put_and_post' === $pathinfo) {
  69. $ret = ['_route' => 'put_and_post'];
  70. if (!in_array($requestMethod, ['PUT', 'POST'])) {
  71. $allow = array_merge($allow, ['PUT', 'POST']);
  72. goto not_put_and_post;
  73. }
  74. return $ret;
  75. }
  76. not_put_and_post:
  77. // put_and_get_and_head
  78. if ('/put_and_post' === $pathinfo) {
  79. $ret = ['_route' => 'put_and_get_and_head'];
  80. if (!in_array($canonicalMethod, ['PUT', 'GET', 'HEAD'])) {
  81. $allow = array_merge($allow, ['PUT', 'GET', 'HEAD']);
  82. goto not_put_and_get_and_head;
  83. }
  84. return $ret;
  85. }
  86. not_put_and_get_and_head:
  87. }
  88. if ('/' === $pathinfo && !$allow) {
  89. throw new Symfony\Component\Routing\Exception\NoConfigurationException();
  90. }
  91. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  92. }
  93. }