url_matcher6.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. if (0 === strpos($pathinfo, '/trailing/simple')) {
  27. // simple_trailing_slash_no_methods
  28. if ('/trailing/simple/no-methods/' === $pathinfo) {
  29. return ['_route' => 'simple_trailing_slash_no_methods'];
  30. }
  31. // simple_trailing_slash_GET_method
  32. if ('/trailing/simple/get-method/' === $pathinfo) {
  33. $ret = ['_route' => 'simple_trailing_slash_GET_method'];
  34. if (!in_array($canonicalMethod, ['GET'])) {
  35. $allow = array_merge($allow, ['GET']);
  36. goto not_simple_trailing_slash_GET_method;
  37. }
  38. return $ret;
  39. }
  40. not_simple_trailing_slash_GET_method:
  41. // simple_trailing_slash_HEAD_method
  42. if ('/trailing/simple/head-method/' === $pathinfo) {
  43. $ret = ['_route' => 'simple_trailing_slash_HEAD_method'];
  44. if (!in_array($requestMethod, ['HEAD'])) {
  45. $allow = array_merge($allow, ['HEAD']);
  46. goto not_simple_trailing_slash_HEAD_method;
  47. }
  48. return $ret;
  49. }
  50. not_simple_trailing_slash_HEAD_method:
  51. // simple_trailing_slash_POST_method
  52. if ('/trailing/simple/post-method/' === $pathinfo) {
  53. $ret = ['_route' => 'simple_trailing_slash_POST_method'];
  54. if (!in_array($requestMethod, ['POST'])) {
  55. $allow = array_merge($allow, ['POST']);
  56. goto not_simple_trailing_slash_POST_method;
  57. }
  58. return $ret;
  59. }
  60. not_simple_trailing_slash_POST_method:
  61. }
  62. elseif (0 === strpos($pathinfo, '/trailing/regex')) {
  63. // regex_trailing_slash_no_methods
  64. if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
  65. return $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_trailing_slash_no_methods']), array ());
  66. }
  67. // regex_trailing_slash_GET_method
  68. if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
  69. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_trailing_slash_GET_method']), array ());
  70. if (!in_array($canonicalMethod, ['GET'])) {
  71. $allow = array_merge($allow, ['GET']);
  72. goto not_regex_trailing_slash_GET_method;
  73. }
  74. return $ret;
  75. }
  76. not_regex_trailing_slash_GET_method:
  77. // regex_trailing_slash_HEAD_method
  78. if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
  79. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_trailing_slash_HEAD_method']), array ());
  80. if (!in_array($requestMethod, ['HEAD'])) {
  81. $allow = array_merge($allow, ['HEAD']);
  82. goto not_regex_trailing_slash_HEAD_method;
  83. }
  84. return $ret;
  85. }
  86. not_regex_trailing_slash_HEAD_method:
  87. // regex_trailing_slash_POST_method
  88. if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
  89. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_trailing_slash_POST_method']), array ());
  90. if (!in_array($requestMethod, ['POST'])) {
  91. $allow = array_merge($allow, ['POST']);
  92. goto not_regex_trailing_slash_POST_method;
  93. }
  94. return $ret;
  95. }
  96. not_regex_trailing_slash_POST_method:
  97. }
  98. elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
  99. // simple_not_trailing_slash_no_methods
  100. if ('/not-trailing/simple/no-methods' === $pathinfo) {
  101. return ['_route' => 'simple_not_trailing_slash_no_methods'];
  102. }
  103. // simple_not_trailing_slash_GET_method
  104. if ('/not-trailing/simple/get-method' === $pathinfo) {
  105. $ret = ['_route' => 'simple_not_trailing_slash_GET_method'];
  106. if (!in_array($canonicalMethod, ['GET'])) {
  107. $allow = array_merge($allow, ['GET']);
  108. goto not_simple_not_trailing_slash_GET_method;
  109. }
  110. return $ret;
  111. }
  112. not_simple_not_trailing_slash_GET_method:
  113. // simple_not_trailing_slash_HEAD_method
  114. if ('/not-trailing/simple/head-method' === $pathinfo) {
  115. $ret = ['_route' => 'simple_not_trailing_slash_HEAD_method'];
  116. if (!in_array($requestMethod, ['HEAD'])) {
  117. $allow = array_merge($allow, ['HEAD']);
  118. goto not_simple_not_trailing_slash_HEAD_method;
  119. }
  120. return $ret;
  121. }
  122. not_simple_not_trailing_slash_HEAD_method:
  123. // simple_not_trailing_slash_POST_method
  124. if ('/not-trailing/simple/post-method' === $pathinfo) {
  125. $ret = ['_route' => 'simple_not_trailing_slash_POST_method'];
  126. if (!in_array($requestMethod, ['POST'])) {
  127. $allow = array_merge($allow, ['POST']);
  128. goto not_simple_not_trailing_slash_POST_method;
  129. }
  130. return $ret;
  131. }
  132. not_simple_not_trailing_slash_POST_method:
  133. }
  134. elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
  135. // regex_not_trailing_slash_no_methods
  136. if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
  137. return $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_not_trailing_slash_no_methods']), array ());
  138. }
  139. // regex_not_trailing_slash_GET_method
  140. if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
  141. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_not_trailing_slash_GET_method']), array ());
  142. if (!in_array($canonicalMethod, ['GET'])) {
  143. $allow = array_merge($allow, ['GET']);
  144. goto not_regex_not_trailing_slash_GET_method;
  145. }
  146. return $ret;
  147. }
  148. not_regex_not_trailing_slash_GET_method:
  149. // regex_not_trailing_slash_HEAD_method
  150. if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
  151. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_not_trailing_slash_HEAD_method']), array ());
  152. if (!in_array($requestMethod, ['HEAD'])) {
  153. $allow = array_merge($allow, ['HEAD']);
  154. goto not_regex_not_trailing_slash_HEAD_method;
  155. }
  156. return $ret;
  157. }
  158. not_regex_not_trailing_slash_HEAD_method:
  159. // regex_not_trailing_slash_POST_method
  160. if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
  161. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'regex_not_trailing_slash_POST_method']), array ());
  162. if (!in_array($requestMethod, ['POST'])) {
  163. $allow = array_merge($allow, ['POST']);
  164. goto not_regex_not_trailing_slash_POST_method;
  165. }
  166. return $ret;
  167. }
  168. not_regex_not_trailing_slash_POST_method:
  169. }
  170. if ('/' === $pathinfo && !$allow) {
  171. throw new Symfony\Component\Routing\Exception\NoConfigurationException();
  172. }
  173. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  174. }
  175. }