url_matcher7.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  4. use Symfony\Component\Routing\RequestContext;
  5. /**
  6. * ProjectUrlMatcher.
  7. *
  8. * This class has been auto-generated
  9. * by the Symfony Routing Component.
  10. */
  11. class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
  12. {
  13. /**
  14. * Constructor.
  15. */
  16. public function __construct(RequestContext $context)
  17. {
  18. $this->context = $context;
  19. }
  20. public function match($pathinfo)
  21. {
  22. $allow = array();
  23. $pathinfo = rawurldecode($pathinfo);
  24. $trimmedPathinfo = rtrim($pathinfo, '/');
  25. $context = $this->context;
  26. $request = $this->request;
  27. $requestMethod = $canonicalMethod = $context->getMethod();
  28. $scheme = $context->getScheme();
  29. if ('HEAD' === $requestMethod) {
  30. $canonicalMethod = 'GET';
  31. }
  32. if (0 === strpos($pathinfo, '/trailing/simple')) {
  33. // simple_trailing_slash_no_methods
  34. if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
  35. if (substr($pathinfo, -1) !== '/') {
  36. return $this->redirect($pathinfo.'/', 'simple_trailing_slash_no_methods');
  37. }
  38. return array('_route' => 'simple_trailing_slash_no_methods');
  39. }
  40. // simple_trailing_slash_GET_method
  41. if ('/trailing/simple/get-method' === $trimmedPathinfo) {
  42. if ('GET' !== $canonicalMethod) {
  43. $allow[] = 'GET';
  44. goto not_simple_trailing_slash_GET_method;
  45. }
  46. if (substr($pathinfo, -1) !== '/') {
  47. return $this->redirect($pathinfo.'/', 'simple_trailing_slash_GET_method');
  48. }
  49. return array('_route' => 'simple_trailing_slash_GET_method');
  50. }
  51. not_simple_trailing_slash_GET_method:
  52. // simple_trailing_slash_HEAD_method
  53. if ('/trailing/simple/head-method' === $trimmedPathinfo) {
  54. if ('HEAD' !== $requestMethod) {
  55. $allow[] = 'HEAD';
  56. goto not_simple_trailing_slash_HEAD_method;
  57. }
  58. if (substr($pathinfo, -1) !== '/') {
  59. return $this->redirect($pathinfo.'/', 'simple_trailing_slash_HEAD_method');
  60. }
  61. return array('_route' => 'simple_trailing_slash_HEAD_method');
  62. }
  63. not_simple_trailing_slash_HEAD_method:
  64. // simple_trailing_slash_POST_method
  65. if ('/trailing/simple/post-method/' === $pathinfo) {
  66. if ('POST' !== $canonicalMethod) {
  67. $allow[] = 'POST';
  68. goto not_simple_trailing_slash_POST_method;
  69. }
  70. return array('_route' => 'simple_trailing_slash_POST_method');
  71. }
  72. not_simple_trailing_slash_POST_method:
  73. }
  74. elseif (0 === strpos($pathinfo, '/trailing/regex')) {
  75. // regex_trailing_slash_no_methods
  76. if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
  77. if (substr($pathinfo, -1) !== '/') {
  78. return $this->redirect($pathinfo.'/', 'regex_trailing_slash_no_methods');
  79. }
  80. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
  81. }
  82. // regex_trailing_slash_GET_method
  83. if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
  84. if ('GET' !== $canonicalMethod) {
  85. $allow[] = 'GET';
  86. goto not_regex_trailing_slash_GET_method;
  87. }
  88. if (substr($pathinfo, -1) !== '/') {
  89. return $this->redirect($pathinfo.'/', 'regex_trailing_slash_GET_method');
  90. }
  91. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
  92. }
  93. not_regex_trailing_slash_GET_method:
  94. // regex_trailing_slash_HEAD_method
  95. if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
  96. if ('HEAD' !== $requestMethod) {
  97. $allow[] = 'HEAD';
  98. goto not_regex_trailing_slash_HEAD_method;
  99. }
  100. if (substr($pathinfo, -1) !== '/') {
  101. return $this->redirect($pathinfo.'/', 'regex_trailing_slash_HEAD_method');
  102. }
  103. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
  104. }
  105. not_regex_trailing_slash_HEAD_method:
  106. // regex_trailing_slash_POST_method
  107. if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#s', $pathinfo, $matches)) {
  108. if ('POST' !== $canonicalMethod) {
  109. $allow[] = 'POST';
  110. goto not_regex_trailing_slash_POST_method;
  111. }
  112. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
  113. }
  114. not_regex_trailing_slash_POST_method:
  115. }
  116. elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
  117. // simple_not_trailing_slash_no_methods
  118. if ('/not-trailing/simple/no-methods' === $pathinfo) {
  119. return array('_route' => 'simple_not_trailing_slash_no_methods');
  120. }
  121. // simple_not_trailing_slash_GET_method
  122. if ('/not-trailing/simple/get-method' === $pathinfo) {
  123. if ('GET' !== $canonicalMethod) {
  124. $allow[] = 'GET';
  125. goto not_simple_not_trailing_slash_GET_method;
  126. }
  127. return array('_route' => 'simple_not_trailing_slash_GET_method');
  128. }
  129. not_simple_not_trailing_slash_GET_method:
  130. // simple_not_trailing_slash_HEAD_method
  131. if ('/not-trailing/simple/head-method' === $pathinfo) {
  132. if ('HEAD' !== $requestMethod) {
  133. $allow[] = 'HEAD';
  134. goto not_simple_not_trailing_slash_HEAD_method;
  135. }
  136. return array('_route' => 'simple_not_trailing_slash_HEAD_method');
  137. }
  138. not_simple_not_trailing_slash_HEAD_method:
  139. // simple_not_trailing_slash_POST_method
  140. if ('/not-trailing/simple/post-method' === $pathinfo) {
  141. if ('POST' !== $canonicalMethod) {
  142. $allow[] = 'POST';
  143. goto not_simple_not_trailing_slash_POST_method;
  144. }
  145. return array('_route' => 'simple_not_trailing_slash_POST_method');
  146. }
  147. not_simple_not_trailing_slash_POST_method:
  148. }
  149. elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
  150. // regex_not_trailing_slash_no_methods
  151. if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  152. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ());
  153. }
  154. // regex_not_trailing_slash_GET_method
  155. if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  156. if ('GET' !== $canonicalMethod) {
  157. $allow[] = 'GET';
  158. goto not_regex_not_trailing_slash_GET_method;
  159. }
  160. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
  161. }
  162. not_regex_not_trailing_slash_GET_method:
  163. // regex_not_trailing_slash_HEAD_method
  164. if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  165. if ('HEAD' !== $requestMethod) {
  166. $allow[] = 'HEAD';
  167. goto not_regex_not_trailing_slash_HEAD_method;
  168. }
  169. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
  170. }
  171. not_regex_not_trailing_slash_HEAD_method:
  172. // regex_not_trailing_slash_POST_method
  173. if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  174. if ('POST' !== $canonicalMethod) {
  175. $allow[] = 'POST';
  176. goto not_regex_not_trailing_slash_POST_method;
  177. }
  178. return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
  179. }
  180. not_regex_not_trailing_slash_POST_method:
  181. }
  182. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  183. }
  184. }