url_matcher1.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\Component\Routing\Matcher\UrlMatcher
  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 ($pathinfo === '/test/baz3/') {
  48. return array('_route' => 'baz3');
  49. }
  50. // baz4
  51. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/$#x', $pathinfo, $matches)) {
  52. $matches['_route'] = 'baz4';
  53. return $matches;
  54. }
  55. // baz5
  56. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/$#x', $pathinfo, $matches)) {
  57. if ($this->context->getMethod() != 'post') {
  58. $allow[] = 'post';
  59. goto not_baz5;
  60. }
  61. $matches['_route'] = 'baz5';
  62. return $matches;
  63. }
  64. not_baz5:
  65. // baz.baz6
  66. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/$#x', $pathinfo, $matches)) {
  67. if ($this->context->getMethod() != 'put') {
  68. $allow[] = 'put';
  69. goto not_bazbaz6;
  70. }
  71. $matches['_route'] = 'baz.baz6';
  72. return $matches;
  73. }
  74. not_bazbaz6:
  75. // foofoo
  76. if ($pathinfo === '/foofoo') {
  77. return array ( 'def' => 'test', '_route' => 'foofoo',);
  78. }
  79. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new NotFoundException();
  80. }
  81. }