url_matcher4.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. $pathinfo = rawurldecode($pathinfo);
  24. $trimmedPathinfo = rtrim($pathinfo, '/');
  25. $context = $this->context;
  26. $request = $this->request;
  27. $requestMethod = $canonicalMethod = $context->getMethod();
  28. $scheme = $context->getScheme();
  29. if ('HEAD' === $requestMethod) {
  30. $canonicalMethod = 'GET';
  31. }
  32. // just_head
  33. if ('/just_head' === $pathinfo) {
  34. if ('HEAD' !== $requestMethod) {
  35. $allow[] = 'HEAD';
  36. goto not_just_head;
  37. }
  38. return array('_route' => 'just_head');
  39. }
  40. not_just_head:
  41. // head_and_get
  42. if ('/head_and_get' === $pathinfo) {
  43. if ('GET' !== $canonicalMethod) {
  44. $allow[] = 'GET';
  45. goto not_head_and_get;
  46. }
  47. return array('_route' => 'head_and_get');
  48. }
  49. not_head_and_get:
  50. // post_and_head
  51. if ('/post_and_get' === $pathinfo) {
  52. if (!in_array($requestMethod, array('POST', 'HEAD'))) {
  53. $allow = array_merge($allow, array('POST', 'HEAD'));
  54. goto not_post_and_head;
  55. }
  56. return array('_route' => 'post_and_head');
  57. }
  58. not_post_and_head:
  59. if (0 === strpos($pathinfo, '/put_and_post')) {
  60. // put_and_post
  61. if ('/put_and_post' === $pathinfo) {
  62. if (!in_array($requestMethod, array('PUT', 'POST'))) {
  63. $allow = array_merge($allow, array('PUT', 'POST'));
  64. goto not_put_and_post;
  65. }
  66. return array('_route' => 'put_and_post');
  67. }
  68. not_put_and_post:
  69. // put_and_get_and_head
  70. if ('/put_and_post' === $pathinfo) {
  71. if (!in_array($canonicalMethod, array('PUT', 'GET'))) {
  72. $allow = array_merge($allow, array('PUT', 'GET'));
  73. goto not_put_and_get_and_head;
  74. }
  75. return array('_route' => 'put_and_get_and_head');
  76. }
  77. not_put_and_get_and_head:
  78. }
  79. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  80. }
  81. }