url_matcher1.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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($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, '/foo')) {
  27. // foo
  28. if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
  29. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo']), array ( 'def' => 'test',));
  30. }
  31. // foofoo
  32. if ('/foofoo' === $pathinfo) {
  33. return array ( 'def' => 'test', '_route' => 'foofoo',);
  34. }
  35. }
  36. elseif (0 === strpos($pathinfo, '/bar')) {
  37. // bar
  38. if (preg_match('#^/bar/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  39. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'bar']), array ());
  40. if (!in_array($canonicalMethod, ['GET', 'HEAD'])) {
  41. $allow = array_merge($allow, ['GET', 'HEAD']);
  42. goto not_bar;
  43. }
  44. return $ret;
  45. }
  46. not_bar:
  47. // barhead
  48. if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  49. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'barhead']), array ());
  50. if (!in_array($canonicalMethod, ['GET'])) {
  51. $allow = array_merge($allow, ['GET']);
  52. goto not_barhead;
  53. }
  54. return $ret;
  55. }
  56. not_barhead:
  57. }
  58. elseif (0 === strpos($pathinfo, '/test')) {
  59. if (0 === strpos($pathinfo, '/test/baz')) {
  60. // baz
  61. if ('/test/baz' === $pathinfo) {
  62. return ['_route' => 'baz'];
  63. }
  64. // baz2
  65. if ('/test/baz.html' === $pathinfo) {
  66. return ['_route' => 'baz2'];
  67. }
  68. // baz3
  69. if ('/test/baz3/' === $pathinfo) {
  70. return ['_route' => 'baz3'];
  71. }
  72. }
  73. // baz4
  74. if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
  75. return $this->mergeDefaults(array_replace($matches, ['_route' => 'baz4']), array ());
  76. }
  77. // baz5
  78. if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
  79. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'baz5']), array ());
  80. if (!in_array($requestMethod, ['POST'])) {
  81. $allow = array_merge($allow, ['POST']);
  82. goto not_baz5;
  83. }
  84. return $ret;
  85. }
  86. not_baz5:
  87. // baz.baz6
  88. if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
  89. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'baz.baz6']), array ());
  90. if (!in_array($requestMethod, ['PUT'])) {
  91. $allow = array_merge($allow, ['PUT']);
  92. goto not_bazbaz6;
  93. }
  94. return $ret;
  95. }
  96. not_bazbaz6:
  97. }
  98. // quoter
  99. if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
  100. return $this->mergeDefaults(array_replace($matches, ['_route' => 'quoter']), array ());
  101. }
  102. // space
  103. if ('/spa ce' === $pathinfo) {
  104. return ['_route' => 'space'];
  105. }
  106. if (0 === strpos($pathinfo, '/a')) {
  107. if (0 === strpos($pathinfo, '/a/b\'b')) {
  108. // foo1
  109. if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  110. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo1']), array ());
  111. }
  112. // bar1
  113. if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
  114. return $this->mergeDefaults(array_replace($matches, ['_route' => 'bar1']), array ());
  115. }
  116. }
  117. // overridden
  118. if (preg_match('#^/a/(?P<var>.*)$#sD', $pathinfo, $matches)) {
  119. return $this->mergeDefaults(array_replace($matches, ['_route' => 'overridden']), array ());
  120. }
  121. if (0 === strpos($pathinfo, '/a/b\'b')) {
  122. // foo2
  123. if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#sD', $pathinfo, $matches)) {
  124. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo2']), array ());
  125. }
  126. // bar2
  127. if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
  128. return $this->mergeDefaults(array_replace($matches, ['_route' => 'bar2']), array ());
  129. }
  130. }
  131. }
  132. elseif (0 === strpos($pathinfo, '/multi')) {
  133. // helloWorld
  134. if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD', $pathinfo, $matches)) {
  135. return $this->mergeDefaults(array_replace($matches, ['_route' => 'helloWorld']), array ( 'who' => 'World!',));
  136. }
  137. // hey
  138. if ('/multi/hey/' === $pathinfo) {
  139. return ['_route' => 'hey'];
  140. }
  141. // overridden2
  142. if ('/multi/new' === $pathinfo) {
  143. return ['_route' => 'overridden2'];
  144. }
  145. }
  146. // foo3
  147. if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  148. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo3']), array ());
  149. }
  150. // bar3
  151. if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
  152. return $this->mergeDefaults(array_replace($matches, ['_route' => 'bar3']), array ());
  153. }
  154. if (0 === strpos($pathinfo, '/aba')) {
  155. // ababa
  156. if ('/ababa' === $pathinfo) {
  157. return ['_route' => 'ababa'];
  158. }
  159. // foo4
  160. if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  161. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo4']), array ());
  162. }
  163. }
  164. $host = $context->getHost();
  165. if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
  166. // route1
  167. if ('/route1' === $pathinfo) {
  168. return ['_route' => 'route1'];
  169. }
  170. // route2
  171. if ('/c2/route2' === $pathinfo) {
  172. return ['_route' => 'route2'];
  173. }
  174. }
  175. if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
  176. // route3
  177. if ('/c2/route3' === $pathinfo) {
  178. return ['_route' => 'route3'];
  179. }
  180. }
  181. if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
  182. // route4
  183. if ('/route4' === $pathinfo) {
  184. return ['_route' => 'route4'];
  185. }
  186. }
  187. if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
  188. // route5
  189. if ('/route5' === $pathinfo) {
  190. return ['_route' => 'route5'];
  191. }
  192. }
  193. // route6
  194. if ('/route6' === $pathinfo) {
  195. return ['_route' => 'route6'];
  196. }
  197. if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
  198. if (0 === strpos($pathinfo, '/route1')) {
  199. // route11
  200. if ('/route11' === $pathinfo) {
  201. return $this->mergeDefaults(array_replace($hostMatches, ['_route' => 'route11']), array ());
  202. }
  203. // route12
  204. if ('/route12' === $pathinfo) {
  205. return $this->mergeDefaults(array_replace($hostMatches, ['_route' => 'route12']), array ( 'var1' => 'val',));
  206. }
  207. // route13
  208. if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  209. return $this->mergeDefaults(array_replace($hostMatches, $matches, ['_route' => 'route13']), array ());
  210. }
  211. // route14
  212. if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  213. return $this->mergeDefaults(array_replace($hostMatches, $matches, ['_route' => 'route14']), array ( 'var1' => 'val',));
  214. }
  215. }
  216. }
  217. if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
  218. // route15
  219. if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  220. return $this->mergeDefaults(array_replace($matches, ['_route' => 'route15']), array ());
  221. }
  222. }
  223. // route16
  224. if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  225. return $this->mergeDefaults(array_replace($matches, ['_route' => 'route16']), array ( 'var1' => 'val',));
  226. }
  227. // route17
  228. if ('/route17' === $pathinfo) {
  229. return ['_route' => 'route17'];
  230. }
  231. // a
  232. if ('/a/a...' === $pathinfo) {
  233. return ['_route' => 'a'];
  234. }
  235. if (0 === strpos($pathinfo, '/a/b')) {
  236. // b
  237. if (preg_match('#^/a/b/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
  238. return $this->mergeDefaults(array_replace($matches, ['_route' => 'b']), array ());
  239. }
  240. // c
  241. if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
  242. return $this->mergeDefaults(array_replace($matches, ['_route' => 'c']), array ());
  243. }
  244. }
  245. if ('/' === $pathinfo && !$allow) {
  246. throw new Symfony\Component\Routing\Exception\NoConfigurationException();
  247. }
  248. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  249. }
  250. }