url_matcher1.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 = 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 ($pathinfo === '/test/baz3/') {
  58. return array('_route' => 'baz3');
  59. }
  60. // baz4
  61. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
  62. $matches['_route'] = 'baz4';
  63. return $matches;
  64. }
  65. // baz5
  66. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
  67. if ($this->context->getMethod() != 'POST') {
  68. $allow[] = 'POST';
  69. goto not_baz5;
  70. }
  71. $matches['_route'] = 'baz5';
  72. return $matches;
  73. }
  74. not_baz5:
  75. // baz.baz6
  76. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
  77. if ($this->context->getMethod() != 'PUT') {
  78. $allow[] = 'PUT';
  79. goto not_bazbaz6;
  80. }
  81. $matches['_route'] = 'baz.baz6';
  82. return $matches;
  83. }
  84. not_bazbaz6:
  85. // foofoo
  86. if ($pathinfo === '/foofoo') {
  87. return array ( 'def' => 'test', '_route' => 'foofoo',);
  88. }
  89. // quoter
  90. if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
  91. $matches['_route'] = 'quoter';
  92. return $matches;
  93. }
  94. // space
  95. if ($pathinfo === '/spa ce') {
  96. return array('_route' => 'space');
  97. }
  98. if (0 === strpos($pathinfo, '/a')) {
  99. if (0 === strpos($pathinfo, '/a/b\'b')) {
  100. // foo1
  101. if (preg_match('#^/a/b\'b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  102. $matches['_route'] = 'foo1';
  103. return $matches;
  104. }
  105. // bar1
  106. if (preg_match('#^/a/b\'b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
  107. $matches['_route'] = 'bar1';
  108. return $matches;
  109. }
  110. // foo2
  111. if (preg_match('#^/a/b\'b/(?P<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
  112. $matches['_route'] = 'foo2';
  113. return $matches;
  114. }
  115. // bar2
  116. if (preg_match('#^/a/b\'b/(?P<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
  117. $matches['_route'] = 'bar2';
  118. return $matches;
  119. }
  120. }
  121. // overriden
  122. if ($pathinfo === '/a/overriden2') {
  123. return array('_route' => 'overriden');
  124. }
  125. // ababa
  126. if ($pathinfo === '/ababa') {
  127. return array('_route' => 'ababa');
  128. }
  129. // foo4
  130. if (preg_match('#^/aba/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  131. $matches['_route'] = 'foo4';
  132. return $matches;
  133. }
  134. }
  135. // foo3
  136. if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
  137. $matches['_route'] = 'foo3';
  138. return $matches;
  139. }
  140. // bar3
  141. if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
  142. $matches['_route'] = 'bar3';
  143. return $matches;
  144. }
  145. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  146. }
  147. }