url_matcher1.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. // 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 ($pathinfo === '/test/baz3/') {
  47. return array('_route' => 'baz3');
  48. }
  49. // baz4
  50. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  51. $matches['_route'] = 'baz4';
  52. return $matches;
  53. }
  54. // baz5
  55. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  56. if ($this->context->getMethod() != 'post') {
  57. $allow[] = 'post';
  58. goto not_baz5;
  59. }
  60. $matches['_route'] = 'baz5';
  61. return $matches;
  62. }
  63. not_baz5:
  64. // baz.baz6
  65. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#x', $pathinfo, $matches)) {
  66. if ($this->context->getMethod() != 'put') {
  67. $allow[] = 'put';
  68. goto not_bazbaz6;
  69. }
  70. $matches['_route'] = 'baz.baz6';
  71. return $matches;
  72. }
  73. not_bazbaz6:
  74. // foofoo
  75. if ($pathinfo === '/foofoo') {
  76. return array ( 'def' => 'test', '_route' => 'foofoo',);
  77. }
  78. if (0 === strpos($pathinfo, '/a')) {
  79. if (0 === strpos($pathinfo, '/a/b')) {
  80. // foo
  81. if (0 === strpos($pathinfo, '/a/b') && preg_match('#^/a/b/(?P<foo>[^/]+?)$#x', $pathinfo, $matches)) {
  82. $matches['_route'] = 'foo';
  83. return $matches;
  84. }
  85. // bar
  86. if (0 === strpos($pathinfo, '/a/b') && preg_match('#^/a/b/(?P<bar>[^/]+?)$#x', $pathinfo, $matches)) {
  87. $matches['_route'] = 'bar';
  88. return $matches;
  89. }
  90. }
  91. }
  92. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  93. }
  94. }