url_matcher2.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. use Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
  4. /**
  5. * ProjectUrlMatcher
  6. *
  7. * This class has been auto-generated
  8. * by the Symfony Routing Component.
  9. */
  10. class ProjectUrlMatcher extends Symfony\Tests\Component\Routing\Fixtures\RedirectableUrlMatcher
  11. {
  12. /**
  13. * Constructor.
  14. */
  15. public function __construct(array $context = array(), array $defaults = array())
  16. {
  17. $this->context = $context;
  18. $this->defaults = $defaults;
  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 (isset($this->context['method']) && !in_array(strtolower($this->context['method']), 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. // baz
  38. if ($pathinfo === '/test/baz') {
  39. return array('_route' => 'baz');
  40. }
  41. // baz2
  42. if ($pathinfo === '/test/baz.html') {
  43. return array('_route' => 'baz2');
  44. }
  45. // baz3
  46. if (rtrim($pathinfo, '/') === '/test/baz3') {
  47. if (substr($pathinfo, -1) !== '/') {
  48. return $this->redirect($pathinfo.'/', 'baz3');
  49. }
  50. return array('_route' => 'baz3');
  51. }
  52. // baz4
  53. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  54. if (substr($pathinfo, -1) !== '/') {
  55. return $this->redirect($pathinfo.'/', 'baz4');
  56. }
  57. $matches['_route'] = 'baz4';
  58. return $matches;
  59. }
  60. // baz5
  61. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  62. if (isset($this->context['method']) && !in_array(strtolower($this->context['method']), array('post'))) {
  63. $allow = array_merge($allow, array('post'));
  64. goto not_baz5;
  65. }
  66. if (substr($pathinfo, -1) !== '/') {
  67. return $this->redirect($pathinfo.'/', 'baz5');
  68. }
  69. $matches['_route'] = 'baz5';
  70. return $matches;
  71. }
  72. not_baz5:
  73. // baz.baz6
  74. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  75. if (isset($this->context['method']) && !in_array(strtolower($this->context['method']), array('put'))) {
  76. $allow = array_merge($allow, array('put'));
  77. goto not_bazbaz6;
  78. }
  79. if (substr($pathinfo, -1) !== '/') {
  80. return $this->redirect($pathinfo.'/', 'baz.baz6');
  81. }
  82. $matches['_route'] = 'baz.baz6';
  83. return $matches;
  84. }
  85. not_bazbaz6:
  86. // foofoo
  87. if ($pathinfo === '/foofoo') {
  88. return array ( 'def' => 'test', '_route' => 'foofoo',);
  89. }
  90. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new NotFoundException();
  91. }
  92. }