url_matcher2.php 13 KB

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