菜谱项目

url_matcher2.php 12KB

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