url_matcher1.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. // foo
  24. if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#x', $pathinfo, $matches)) {
  25. return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo'));
  26. }
  27. // bar
  28. if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  29. if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
  30. $allow = array_merge($allow, array('GET', 'HEAD'));
  31. goto not_bar;
  32. }
  33. $matches['_route'] = 'bar';
  34. return $matches;
  35. }
  36. not_bar:
  37. // barhead
  38. if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  39. if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
  40. $allow = array_merge($allow, array('GET', 'HEAD'));
  41. goto not_barhead;
  42. }
  43. $matches['_route'] = 'barhead';
  44. return $matches;
  45. }
  46. not_barhead:
  47. // baz
  48. if ($pathinfo === '/test/baz') {
  49. return array('_route' => 'baz');
  50. }
  51. // baz2
  52. if ($pathinfo === '/test/baz.html') {
  53. return array('_route' => 'baz2');
  54. }
  55. // baz3
  56. if ($pathinfo === '/test/baz3/') {
  57. return array('_route' => 'baz3');
  58. }
  59. // baz4
  60. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  61. $matches['_route'] = 'baz4';
  62. return $matches;
  63. }
  64. // baz5
  65. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  66. if ($this->context->getMethod() != 'POST') {
  67. $allow[] = 'POST';
  68. goto not_baz5;
  69. }
  70. $matches['_route'] = 'baz5';
  71. return $matches;
  72. }
  73. not_baz5:
  74. // baz.baz6
  75. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  76. if ($this->context->getMethod() != 'PUT') {
  77. $allow[] = 'PUT';
  78. goto not_bazbaz6;
  79. }
  80. $matches['_route'] = 'baz.baz6';
  81. return $matches;
  82. }
  83. not_bazbaz6:
  84. // foofoo
  85. if ($pathinfo === '/foofoo') {
  86. return array ( 'def' => 'test', '_route' => 'foofoo',);
  87. }
  88. if (0 === strpos($pathinfo, '/a')) {
  89. if (0 === strpos($pathinfo, '/a/b')) {
  90. // foo
  91. if (preg_match('#^/a/b/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  92. $matches['_route'] = 'foo';
  93. return $matches;
  94. }
  95. // bar
  96. if (preg_match('#^/a/b/(?P<bar>[^/]+?)$#x', $pathinfo, $matches)) {
  97. $matches['_route'] = 'bar';
  98. return $matches;
  99. }
  100. // foo1
  101. if (preg_match('#^/a/b/(?P<foo1>[^/]+?)$#x', $pathinfo, $matches)) {
  102. $matches['_route'] = 'foo1';
  103. return $matches;
  104. }
  105. // bar1
  106. if (preg_match('#^/a/b/(?P<bar1>[^/]+?)$#x', $pathinfo, $matches)) {
  107. $matches['_route'] = 'bar1';
  108. return $matches;
  109. }
  110. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  111. }
  112. // ababa
  113. if ($pathinfo === '/ababa') {
  114. return array('_route' => 'ababa');
  115. }
  116. // foo
  117. if (preg_match('#^/aba/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  118. $matches['_route'] = 'foo';
  119. return $matches;
  120. }
  121. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  122. }
  123. // foo
  124. if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  125. $matches['_route'] = 'foo';
  126. return $matches;
  127. }
  128. // bar
  129. if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<bar>[^/]+?)$#x', $pathinfo, $matches)) {
  130. $matches['_route'] = 'bar';
  131. return $matches;
  132. }
  133. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  134. }
  135. }