菜谱项目

url_matcher7.php 9.5KB

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