菜谱项目

url_matcher5.php 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  4. use Symfony\Component\Routing\RequestContext;
  5. /**
  6. * This class has been auto-generated
  7. * by the Symfony Routing Component.
  8. */
  9. class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
  10. {
  11. public function __construct(RequestContext $context)
  12. {
  13. $this->context = $context;
  14. }
  15. public function match($pathinfo)
  16. {
  17. $allow = array();
  18. $pathinfo = rawurldecode($pathinfo);
  19. $trimmedPathinfo = rtrim($pathinfo, '/');
  20. $context = $this->context;
  21. $request = $this->request;
  22. $requestMethod = $canonicalMethod = $context->getMethod();
  23. $scheme = $context->getScheme();
  24. if ('HEAD' === $requestMethod) {
  25. $canonicalMethod = 'GET';
  26. }
  27. if (0 === strpos($pathinfo, '/a')) {
  28. // a_first
  29. if ('/a/11' === $pathinfo) {
  30. return array('_route' => 'a_first');
  31. }
  32. // a_second
  33. if ('/a/22' === $pathinfo) {
  34. return array('_route' => 'a_second');
  35. }
  36. // a_third
  37. if ('/a/333' === $pathinfo) {
  38. return array('_route' => 'a_third');
  39. }
  40. }
  41. // a_wildcard
  42. if (preg_match('#^/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  43. return $this->mergeDefaults(array_replace($matches, array('_route' => 'a_wildcard')), array ());
  44. }
  45. if (0 === strpos($pathinfo, '/a')) {
  46. // a_fourth
  47. if ('/a/44' === $trimmedPathinfo) {
  48. if (substr($pathinfo, -1) !== '/') {
  49. return $this->redirect($pathinfo.'/', 'a_fourth');
  50. }
  51. return array('_route' => 'a_fourth');
  52. }
  53. // a_fifth
  54. if ('/a/55' === $trimmedPathinfo) {
  55. if (substr($pathinfo, -1) !== '/') {
  56. return $this->redirect($pathinfo.'/', 'a_fifth');
  57. }
  58. return array('_route' => 'a_fifth');
  59. }
  60. // a_sixth
  61. if ('/a/66' === $trimmedPathinfo) {
  62. if (substr($pathinfo, -1) !== '/') {
  63. return $this->redirect($pathinfo.'/', 'a_sixth');
  64. }
  65. return array('_route' => 'a_sixth');
  66. }
  67. }
  68. // nested_wildcard
  69. if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
  70. return $this->mergeDefaults(array_replace($matches, array('_route' => 'nested_wildcard')), array ());
  71. }
  72. if (0 === strpos($pathinfo, '/nested/group')) {
  73. // nested_a
  74. if ('/nested/group/a' === $trimmedPathinfo) {
  75. if (substr($pathinfo, -1) !== '/') {
  76. return $this->redirect($pathinfo.'/', 'nested_a');
  77. }
  78. return array('_route' => 'nested_a');
  79. }
  80. // nested_b
  81. if ('/nested/group/b' === $trimmedPathinfo) {
  82. if (substr($pathinfo, -1) !== '/') {
  83. return $this->redirect($pathinfo.'/', 'nested_b');
  84. }
  85. return array('_route' => 'nested_b');
  86. }
  87. // nested_c
  88. if ('/nested/group/c' === $trimmedPathinfo) {
  89. if (substr($pathinfo, -1) !== '/') {
  90. return $this->redirect($pathinfo.'/', 'nested_c');
  91. }
  92. return array('_route' => 'nested_c');
  93. }
  94. }
  95. elseif (0 === strpos($pathinfo, '/slashed/group')) {
  96. // slashed_a
  97. if ('/slashed/group' === $trimmedPathinfo) {
  98. if (substr($pathinfo, -1) !== '/') {
  99. return $this->redirect($pathinfo.'/', 'slashed_a');
  100. }
  101. return array('_route' => 'slashed_a');
  102. }
  103. // slashed_b
  104. if ('/slashed/group/b' === $trimmedPathinfo) {
  105. if (substr($pathinfo, -1) !== '/') {
  106. return $this->redirect($pathinfo.'/', 'slashed_b');
  107. }
  108. return array('_route' => 'slashed_b');
  109. }
  110. // slashed_c
  111. if ('/slashed/group/c' === $trimmedPathinfo) {
  112. if (substr($pathinfo, -1) !== '/') {
  113. return $this->redirect($pathinfo.'/', 'slashed_c');
  114. }
  115. return array('_route' => 'slashed_c');
  116. }
  117. }
  118. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  119. }
  120. }