url_matcher2.php 12 KB

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