PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php

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