url_matcher2.php 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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\Tests\Component\Routing\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 = urldecode($pathinfo);
  24. // foo
  25. if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
  26. return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo'));
  27. }
  28. // bar
  29. if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  30. if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
  31. $allow = array_merge($allow, array('GET', 'HEAD'));
  32. goto not_bar;
  33. }
  34. $matches['_route'] = 'bar';
  35. return $matches;
  36. }
  37. not_bar:
  38. // barhead
  39. if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  40. if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
  41. $allow = array_merge($allow, array('GET', 'HEAD'));
  42. goto not_barhead;
  43. }
  44. $matches['_route'] = 'barhead';
  45. return $matches;
  46. }
  47. not_barhead:
  48. // baz
  49. if ($pathinfo === '/test/baz') {
  50. return array('_route' => 'baz');
  51. }
  52. // baz2
  53. if ($pathinfo === '/test/baz.html') {
  54. return array('_route' => 'baz2');
  55. }
  56. // baz3
  57. if (rtrim($pathinfo, '/') === '/test/baz3') {
  58. if (substr($pathinfo, -1) !== '/') {
  59. return $this->redirect($pathinfo.'/', 'baz3');
  60. }
  61. return array('_route' => 'baz3');
  62. }
  63. // baz4
  64. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#s', $pathinfo, $matches)) {
  65. if (substr($pathinfo, -1) !== '/') {
  66. return $this->redirect($pathinfo.'/', 'baz4');
  67. }
  68. $matches['_route'] = 'baz4';
  69. return $matches;
  70. }
  71. // baz5
  72. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#s', $pathinfo, $matches)) {
  73. if ($this->context->getMethod() != 'POST') {
  74. $allow[] = 'POST';
  75. goto not_baz5;
  76. }
  77. if (substr($pathinfo, -1) !== '/') {
  78. return $this->redirect($pathinfo.'/', 'baz5');
  79. }
  80. $matches['_route'] = 'baz5';
  81. return $matches;
  82. }
  83. not_baz5:
  84. // baz.baz6
  85. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#s', $pathinfo, $matches)) {
  86. if ($this->context->getMethod() != 'PUT') {
  87. $allow[] = 'PUT';
  88. goto not_bazbaz6;
  89. }
  90. if (substr($pathinfo, -1) !== '/') {
  91. return $this->redirect($pathinfo.'/', 'baz.baz6');
  92. }
  93. $matches['_route'] = 'baz.baz6';
  94. return $matches;
  95. }
  96. not_bazbaz6:
  97. // foofoo
  98. if ($pathinfo === '/foofoo') {
  99. return array ( 'def' => 'test', '_route' => 'foofoo',);
  100. }
  101. // quoter
  102. if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
  103. $matches['_route'] = 'quoter';
  104. return $matches;
  105. }
  106. // space
  107. if ($pathinfo === '/spa ce') {
  108. return array('_route' => 'space');
  109. }
  110. if (0 === strpos($pathinfo, '/a')) {
  111. if (0 === strpos($pathinfo, '/a/b\'b')) {
  112. // foo1
  113. if (preg_match('#^/a/b\'b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  114. $matches['_route'] = 'foo1';
  115. return $matches;
  116. }
  117. // bar1
  118. if (preg_match('#^/a/b\'b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
  119. $matches['_route'] = 'bar1';
  120. return $matches;
  121. }
  122. // foo2
  123. if (preg_match('#^/a/b\'b/(?P<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
  124. $matches['_route'] = 'foo2';
  125. return $matches;
  126. }
  127. // bar2
  128. if (preg_match('#^/a/b\'b/(?P<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
  129. $matches['_route'] = 'bar2';
  130. return $matches;
  131. }
  132. }
  133. // overriden
  134. if ($pathinfo === '/a/overriden2') {
  135. return array('_route' => 'overriden');
  136. }
  137. // ababa
  138. if ($pathinfo === '/ababa') {
  139. return array('_route' => 'ababa');
  140. }
  141. // foo4
  142. if (preg_match('#^/aba/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  143. $matches['_route'] = 'foo4';
  144. return $matches;
  145. }
  146. }
  147. // foo3
  148. if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  149. $matches['_route'] = 'foo3';
  150. return $matches;
  151. }
  152. // bar3
  153. if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
  154. $matches['_route'] = 'bar3';
  155. return $matches;
  156. }
  157. // secure
  158. if ($pathinfo === '/secure') {
  159. if ($this->context->getScheme() !== 'https') {
  160. return $this->redirect($pathinfo, 'secure', 'https');
  161. }
  162. return array('_route' => 'secure');
  163. }
  164. // nonsecure
  165. if ($pathinfo === '/nonsecure') {
  166. if ($this->context->getScheme() !== 'http') {
  167. return $this->redirect($pathinfo, 'nonsecure', 'http');
  168. }
  169. return array('_route' => 'nonsecure');
  170. }
  171. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  172. }
  173. }