菜谱项目

url_matcher6.php 8.5KB

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