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