url_matcher1.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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\Component\Routing\Matcher\UrlMatcher
  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. return array_merge($this->mergeDefaults($matches, array ()), array('_route' => 'bar'));
  34. }
  35. not_bar:
  36. // baz
  37. if ($pathinfo === '/test/baz') {
  38. return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz'));
  39. }
  40. // baz2
  41. if ($pathinfo === '/test/baz.html') {
  42. return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz2'));
  43. }
  44. // baz3
  45. if (rtrim($pathinfo, '/') === '/test/baz3') {
  46. if (substr($pathinfo, -1) !== '/') {
  47. return array('_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'url' => $this->context['base_url'].$pathinfo.'/', 'permanent' => true, '_route' => 'baz3');
  48. }
  49. return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz3'));
  50. }
  51. // baz4
  52. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  53. if (substr($pathinfo, -1) !== '/') {
  54. return array('_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'url' => $this->context['base_url'].$pathinfo.'/', 'permanent' => true, '_route' => 'baz4');
  55. }
  56. return array_merge($this->mergeDefaults($matches, array ()), array('_route' => 'baz4'));
  57. }
  58. // baz5
  59. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  60. if (isset($this->context['method']) && !in_array(strtolower($this->context['method']), array('post'))) {
  61. $allow = array_merge($allow, array('post'));
  62. goto not_baz5;
  63. }
  64. if (substr($pathinfo, -1) !== '/') {
  65. return array('_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'url' => $this->context['base_url'].$pathinfo.'/', 'permanent' => true, '_route' => 'baz5');
  66. }
  67. return array_merge($this->mergeDefaults($matches, array ()), array('_route' => 'baz5'));
  68. }
  69. not_baz5:
  70. // baz.baz6
  71. if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $pathinfo, $matches)) {
  72. if (isset($this->context['method']) && !in_array(strtolower($this->context['method']), array('put'))) {
  73. $allow = array_merge($allow, array('put'));
  74. goto not_bazbaz6;
  75. }
  76. if (substr($pathinfo, -1) !== '/') {
  77. return array('_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'url' => $this->context['base_url'].$pathinfo.'/', 'permanent' => true, '_route' => 'baz.baz6');
  78. }
  79. return array_merge($this->mergeDefaults($matches, array ()), array('_route' => 'baz.baz6'));
  80. }
  81. not_bazbaz6:
  82. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new NotFoundException();
  83. }
  84. }