url_matcher5.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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, '/a')) {
  27. // a_first
  28. if ('/a/11' === $pathinfo) {
  29. return ['_route' => 'a_first'];
  30. }
  31. // a_second
  32. if ('/a/22' === $pathinfo) {
  33. return ['_route' => 'a_second'];
  34. }
  35. // a_third
  36. if ('/a/333' === $pathinfo) {
  37. return ['_route' => 'a_third'];
  38. }
  39. }
  40. // a_wildcard
  41. if (preg_match('#^/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
  42. return $this->mergeDefaults(array_replace($matches, ['_route' => 'a_wildcard']), array ());
  43. }
  44. if (0 === strpos($pathinfo, '/a')) {
  45. // a_fourth
  46. if ('/a/44' === $trimmedPathinfo) {
  47. $ret = ['_route' => 'a_fourth'];
  48. if ('/' === substr($pathinfo, -1)) {
  49. // no-op
  50. } elseif ('GET' !== $canonicalMethod) {
  51. goto not_a_fourth;
  52. } else {
  53. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fourth'));
  54. }
  55. return $ret;
  56. }
  57. not_a_fourth:
  58. // a_fifth
  59. if ('/a/55' === $trimmedPathinfo) {
  60. $ret = ['_route' => 'a_fifth'];
  61. if ('/' === substr($pathinfo, -1)) {
  62. // no-op
  63. } elseif ('GET' !== $canonicalMethod) {
  64. goto not_a_fifth;
  65. } else {
  66. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fifth'));
  67. }
  68. return $ret;
  69. }
  70. not_a_fifth:
  71. // a_sixth
  72. if ('/a/66' === $trimmedPathinfo) {
  73. $ret = ['_route' => 'a_sixth'];
  74. if ('/' === substr($pathinfo, -1)) {
  75. // no-op
  76. } elseif ('GET' !== $canonicalMethod) {
  77. goto not_a_sixth;
  78. } else {
  79. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_sixth'));
  80. }
  81. return $ret;
  82. }
  83. not_a_sixth:
  84. }
  85. // nested_wildcard
  86. if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
  87. return $this->mergeDefaults(array_replace($matches, ['_route' => 'nested_wildcard']), array ());
  88. }
  89. if (0 === strpos($pathinfo, '/nested/group')) {
  90. // nested_a
  91. if ('/nested/group/a' === $trimmedPathinfo) {
  92. $ret = ['_route' => 'nested_a'];
  93. if ('/' === substr($pathinfo, -1)) {
  94. // no-op
  95. } elseif ('GET' !== $canonicalMethod) {
  96. goto not_nested_a;
  97. } else {
  98. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_a'));
  99. }
  100. return $ret;
  101. }
  102. not_nested_a:
  103. // nested_b
  104. if ('/nested/group/b' === $trimmedPathinfo) {
  105. $ret = ['_route' => 'nested_b'];
  106. if ('/' === substr($pathinfo, -1)) {
  107. // no-op
  108. } elseif ('GET' !== $canonicalMethod) {
  109. goto not_nested_b;
  110. } else {
  111. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_b'));
  112. }
  113. return $ret;
  114. }
  115. not_nested_b:
  116. // nested_c
  117. if ('/nested/group/c' === $trimmedPathinfo) {
  118. $ret = ['_route' => 'nested_c'];
  119. if ('/' === substr($pathinfo, -1)) {
  120. // no-op
  121. } elseif ('GET' !== $canonicalMethod) {
  122. goto not_nested_c;
  123. } else {
  124. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_c'));
  125. }
  126. return $ret;
  127. }
  128. not_nested_c:
  129. }
  130. elseif (0 === strpos($pathinfo, '/slashed/group')) {
  131. // slashed_a
  132. if ('/slashed/group' === $trimmedPathinfo) {
  133. $ret = ['_route' => 'slashed_a'];
  134. if ('/' === substr($pathinfo, -1)) {
  135. // no-op
  136. } elseif ('GET' !== $canonicalMethod) {
  137. goto not_slashed_a;
  138. } else {
  139. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_a'));
  140. }
  141. return $ret;
  142. }
  143. not_slashed_a:
  144. // slashed_b
  145. if ('/slashed/group/b' === $trimmedPathinfo) {
  146. $ret = ['_route' => 'slashed_b'];
  147. if ('/' === substr($pathinfo, -1)) {
  148. // no-op
  149. } elseif ('GET' !== $canonicalMethod) {
  150. goto not_slashed_b;
  151. } else {
  152. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_b'));
  153. }
  154. return $ret;
  155. }
  156. not_slashed_b:
  157. // slashed_c
  158. if ('/slashed/group/c' === $trimmedPathinfo) {
  159. $ret = ['_route' => 'slashed_c'];
  160. if ('/' === substr($pathinfo, -1)) {
  161. // no-op
  162. } elseif ('GET' !== $canonicalMethod) {
  163. goto not_slashed_c;
  164. } else {
  165. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_c'));
  166. }
  167. return $ret;
  168. }
  169. not_slashed_c:
  170. }
  171. if ('/' === $pathinfo && !$allow) {
  172. throw new Symfony\Component\Routing\Exception\NoConfigurationException();
  173. }
  174. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  175. }
  176. }