url_matcher7.php 11 KB

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