url_matcher2.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. use Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
  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, array $defaults = array())
  17. {
  18. $this->context = $context;
  19. $this->defaults = $defaults;
  20. }
  21. public function match($pathinfo)
  22. {
  23. $allow = array();
  24. // foo
  25. if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#x', $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>[^/\.]+?)$#x', $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. // baz
  39. if ($pathinfo === '/test/baz') {
  40. return array('_route' => 'baz');
  41. }
  42. // baz2
  43. if ($pathinfo === '/test/baz.html') {
  44. return array('_route' => 'baz2');
  45. }
  46. // baz3
  47. if (rtrim($pathinfo, '/') === '/test/baz3') {
  48. if (substr($pathinfo, -1) !== '/') {
  49. return $this->redirect($pathinfo.'/', 'baz3');
  50. }
  51. return array('_route' => 'baz3');
  52. }
  53. // baz4
  54. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  55. if (substr($pathinfo, -1) !== '/') {
  56. return $this->redirect($pathinfo.'/', 'baz4');
  57. }
  58. $matches['_route'] = 'baz4';
  59. return $matches;
  60. }
  61. // baz5
  62. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  63. if ($this->context->getMethod() != 'post') {
  64. $allow[] = 'post';
  65. goto not_baz5;
  66. }
  67. if (substr($pathinfo, -1) !== '/') {
  68. return $this->redirect($pathinfo.'/', '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. if (substr($pathinfo, -1) !== '/') {
  81. return $this->redirect($pathinfo.'/', 'baz.baz6');
  82. }
  83. $matches['_route'] = 'baz.baz6';
  84. return $matches;
  85. }
  86. not_bazbaz6:
  87. // foofoo
  88. if ($pathinfo === '/foofoo') {
  89. return array ( 'def' => 'test', '_route' => 'foofoo',);
  90. }
  91. // secure
  92. if ($pathinfo === '/secure') {
  93. if ($this->context->getScheme() !== 'https') {
  94. return $this->redirect($pathinfo, 'secure', 'https');
  95. }
  96. return array('_route' => 'secure');
  97. }
  98. // nonsecure
  99. if ($pathinfo === '/nonsecure') {
  100. if ($this->context->getScheme() !== 'http') {
  101. return $this->redirect($pathinfo, 'nonsecure', 'http');
  102. }
  103. return array('_route' => 'nonsecure');
  104. }
  105. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new NotFoundException();
  106. }
  107. }