url_matcher2.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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, '/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' === $trimmedPathinfo) {
  70. $ret = ['_route' => 'baz3'];
  71. if ('/' === substr($pathinfo, -1)) {
  72. // no-op
  73. } elseif ('GET' !== $canonicalMethod) {
  74. goto not_baz3;
  75. } else {
  76. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz3'));
  77. }
  78. return $ret;
  79. }
  80. not_baz3:
  81. }
  82. // baz4
  83. if (preg_match('#^/test/(?P<foo>[^/]++)/?$#sD', $pathinfo, $matches)) {
  84. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'baz4']), array ());
  85. if ('/' === substr($pathinfo, -1)) {
  86. // no-op
  87. } elseif ('GET' !== $canonicalMethod) {
  88. goto not_baz4;
  89. } else {
  90. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz4'));
  91. }
  92. return $ret;
  93. }
  94. not_baz4:
  95. // baz5
  96. if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
  97. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'baz5']), array ());
  98. if (!in_array($requestMethod, ['POST'])) {
  99. $allow = array_merge($allow, ['POST']);
  100. goto not_baz5;
  101. }
  102. return $ret;
  103. }
  104. not_baz5:
  105. // baz.baz6
  106. if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
  107. $ret = $this->mergeDefaults(array_replace($matches, ['_route' => 'baz.baz6']), array ());
  108. if (!in_array($requestMethod, ['PUT'])) {
  109. $allow = array_merge($allow, ['PUT']);
  110. goto not_bazbaz6;
  111. }
  112. return $ret;
  113. }
  114. not_bazbaz6:
  115. }
  116. // quoter
  117. if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
  118. return $this->mergeDefaults(array_replace($matches, ['_route' => 'quoter']), array ());
  119. }
  120. // space
  121. if ('/spa ce' === $pathinfo) {
  122. return ['_route' => 'space'];
  123. }
  124. if (0 === strpos($pathinfo, '/a')) {
  125. if (0 === strpos($pathinfo, '/a/b\'b')) {
  126. // foo1
  127. if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  128. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo1']), array ());
  129. }
  130. // bar1
  131. if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
  132. return $this->mergeDefaults(array_replace($matches, ['_route' => 'bar1']), array ());
  133. }
  134. }
  135. // overridden
  136. if (preg_match('#^/a/(?P<var>.*)$#sD', $pathinfo, $matches)) {
  137. return $this->mergeDefaults(array_replace($matches, ['_route' => 'overridden']), array ());
  138. }
  139. if (0 === strpos($pathinfo, '/a/b\'b')) {
  140. // foo2
  141. if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#sD', $pathinfo, $matches)) {
  142. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo2']), array ());
  143. }
  144. // bar2
  145. if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
  146. return $this->mergeDefaults(array_replace($matches, ['_route' => 'bar2']), array ());
  147. }
  148. }
  149. }
  150. elseif (0 === strpos($pathinfo, '/multi')) {
  151. // helloWorld
  152. if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD', $pathinfo, $matches)) {
  153. return $this->mergeDefaults(array_replace($matches, ['_route' => 'helloWorld']), array ( 'who' => 'World!',));
  154. }
  155. // hey
  156. if ('/multi/hey' === $trimmedPathinfo) {
  157. $ret = ['_route' => 'hey'];
  158. if ('/' === substr($pathinfo, -1)) {
  159. // no-op
  160. } elseif ('GET' !== $canonicalMethod) {
  161. goto not_hey;
  162. } else {
  163. return array_replace($ret, $this->redirect($rawPathinfo.'/', 'hey'));
  164. }
  165. return $ret;
  166. }
  167. not_hey:
  168. // overridden2
  169. if ('/multi/new' === $pathinfo) {
  170. return ['_route' => 'overridden2'];
  171. }
  172. }
  173. // foo3
  174. if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  175. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo3']), array ());
  176. }
  177. // bar3
  178. if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
  179. return $this->mergeDefaults(array_replace($matches, ['_route' => 'bar3']), array ());
  180. }
  181. if (0 === strpos($pathinfo, '/aba')) {
  182. // ababa
  183. if ('/ababa' === $pathinfo) {
  184. return ['_route' => 'ababa'];
  185. }
  186. // foo4
  187. if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
  188. return $this->mergeDefaults(array_replace($matches, ['_route' => 'foo4']), array ());
  189. }
  190. }
  191. $host = $context->getHost();
  192. if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
  193. // route1
  194. if ('/route1' === $pathinfo) {
  195. return ['_route' => 'route1'];
  196. }
  197. // route2
  198. if ('/c2/route2' === $pathinfo) {
  199. return ['_route' => 'route2'];
  200. }
  201. }
  202. if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
  203. // route3
  204. if ('/c2/route3' === $pathinfo) {
  205. return ['_route' => 'route3'];
  206. }
  207. }
  208. if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
  209. // route4
  210. if ('/route4' === $pathinfo) {
  211. return ['_route' => 'route4'];
  212. }
  213. }
  214. if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
  215. // route5
  216. if ('/route5' === $pathinfo) {
  217. return ['_route' => 'route5'];
  218. }
  219. }
  220. // route6
  221. if ('/route6' === $pathinfo) {
  222. return ['_route' => 'route6'];
  223. }
  224. if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
  225. if (0 === strpos($pathinfo, '/route1')) {
  226. // route11
  227. if ('/route11' === $pathinfo) {
  228. return $this->mergeDefaults(array_replace($hostMatches, ['_route' => 'route11']), array ());
  229. }
  230. // route12
  231. if ('/route12' === $pathinfo) {
  232. return $this->mergeDefaults(array_replace($hostMatches, ['_route' => 'route12']), array ( 'var1' => 'val',));
  233. }
  234. // route13
  235. if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  236. return $this->mergeDefaults(array_replace($hostMatches, $matches, ['_route' => 'route13']), array ());
  237. }
  238. // route14
  239. if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  240. return $this->mergeDefaults(array_replace($hostMatches, $matches, ['_route' => 'route14']), array ( 'var1' => 'val',));
  241. }
  242. }
  243. }
  244. if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
  245. // route15
  246. if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  247. return $this->mergeDefaults(array_replace($matches, ['_route' => 'route15']), array ());
  248. }
  249. }
  250. // route16
  251. if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
  252. return $this->mergeDefaults(array_replace($matches, ['_route' => 'route16']), array ( 'var1' => 'val',));
  253. }
  254. // route17
  255. if ('/route17' === $pathinfo) {
  256. return ['_route' => 'route17'];
  257. }
  258. // a
  259. if ('/a/a...' === $pathinfo) {
  260. return ['_route' => 'a'];
  261. }
  262. if (0 === strpos($pathinfo, '/a/b')) {
  263. // b
  264. if (preg_match('#^/a/b/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
  265. return $this->mergeDefaults(array_replace($matches, ['_route' => 'b']), array ());
  266. }
  267. // c
  268. if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
  269. return $this->mergeDefaults(array_replace($matches, ['_route' => 'c']), array ());
  270. }
  271. }
  272. // secure
  273. if ('/secure' === $pathinfo) {
  274. $ret = ['_route' => 'secure'];
  275. $requiredSchemes = array ( 'https' => 0,);
  276. if (!isset($requiredSchemes[$context->getScheme()])) {
  277. if ('GET' !== $canonicalMethod) {
  278. goto not_secure;
  279. }
  280. return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes)));
  281. }
  282. return $ret;
  283. }
  284. not_secure:
  285. // nonsecure
  286. if ('/nonsecure' === $pathinfo) {
  287. $ret = ['_route' => 'nonsecure'];
  288. $requiredSchemes = array ( 'http' => 0,);
  289. if (!isset($requiredSchemes[$context->getScheme()])) {
  290. if ('GET' !== $canonicalMethod) {
  291. goto not_nonsecure;
  292. }
  293. return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes)));
  294. }
  295. return $ret;
  296. }
  297. not_nonsecure:
  298. if ('/' === $pathinfo && !$allow) {
  299. throw new Symfony\Component\Routing\Exception\NoConfigurationException();
  300. }
  301. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  302. }
  303. }