url_matcher5.php 4.7 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\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. $trimmedPathinfo = rtrim($pathinfo, '/');
  25. $context = $this->context;
  26. $request = $this->request;
  27. $requestMethod = $canonicalMethod = $context->getMethod();
  28. $scheme = $context->getScheme();
  29. if ('HEAD' === $requestMethod) {
  30. $canonicalMethod = 'GET';
  31. }
  32. if (0 === strpos($pathinfo, '/a')) {
  33. // a_first
  34. if ('/a/11' === $pathinfo) {
  35. return array('_route' => 'a_first');
  36. }
  37. // a_second
  38. if ('/a/22' === $pathinfo) {
  39. return array('_route' => 'a_second');
  40. }
  41. // a_third
  42. if ('/a/333' === $pathinfo) {
  43. return array('_route' => 'a_third');
  44. }
  45. }
  46. // a_wildcard
  47. if (preg_match('#^/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  48. return $this->mergeDefaults(array_replace($matches, array('_route' => 'a_wildcard')), array ());
  49. }
  50. if (0 === strpos($pathinfo, '/a')) {
  51. // a_fourth
  52. if ('/a/44' === $trimmedPathinfo) {
  53. if (substr($pathinfo, -1) !== '/') {
  54. return $this->redirect($pathinfo.'/', 'a_fourth');
  55. }
  56. return array('_route' => 'a_fourth');
  57. }
  58. // a_fifth
  59. if ('/a/55' === $trimmedPathinfo) {
  60. if (substr($pathinfo, -1) !== '/') {
  61. return $this->redirect($pathinfo.'/', 'a_fifth');
  62. }
  63. return array('_route' => 'a_fifth');
  64. }
  65. // a_sixth
  66. if ('/a/66' === $trimmedPathinfo) {
  67. if (substr($pathinfo, -1) !== '/') {
  68. return $this->redirect($pathinfo.'/', 'a_sixth');
  69. }
  70. return array('_route' => 'a_sixth');
  71. }
  72. }
  73. // nested_wildcard
  74. if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  75. return $this->mergeDefaults(array_replace($matches, array('_route' => 'nested_wildcard')), array ());
  76. }
  77. if (0 === strpos($pathinfo, '/nested/group')) {
  78. // nested_a
  79. if ('/nested/group/a' === $trimmedPathinfo) {
  80. if (substr($pathinfo, -1) !== '/') {
  81. return $this->redirect($pathinfo.'/', 'nested_a');
  82. }
  83. return array('_route' => 'nested_a');
  84. }
  85. // nested_b
  86. if ('/nested/group/b' === $trimmedPathinfo) {
  87. if (substr($pathinfo, -1) !== '/') {
  88. return $this->redirect($pathinfo.'/', 'nested_b');
  89. }
  90. return array('_route' => 'nested_b');
  91. }
  92. // nested_c
  93. if ('/nested/group/c' === $trimmedPathinfo) {
  94. if (substr($pathinfo, -1) !== '/') {
  95. return $this->redirect($pathinfo.'/', 'nested_c');
  96. }
  97. return array('_route' => 'nested_c');
  98. }
  99. }
  100. elseif (0 === strpos($pathinfo, '/slashed/group')) {
  101. // slashed_a
  102. if ('/slashed/group' === $trimmedPathinfo) {
  103. if (substr($pathinfo, -1) !== '/') {
  104. return $this->redirect($pathinfo.'/', 'slashed_a');
  105. }
  106. return array('_route' => 'slashed_a');
  107. }
  108. // slashed_b
  109. if ('/slashed/group/b' === $trimmedPathinfo) {
  110. if (substr($pathinfo, -1) !== '/') {
  111. return $this->redirect($pathinfo.'/', 'slashed_b');
  112. }
  113. return array('_route' => 'slashed_b');
  114. }
  115. // slashed_c
  116. if ('/slashed/group/c' === $trimmedPathinfo) {
  117. if (substr($pathinfo, -1) !== '/') {
  118. return $this->redirect($pathinfo.'/', 'slashed_c');
  119. }
  120. return array('_route' => 'slashed_c');
  121. }
  122. }
  123. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  124. }
  125. }