/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php

https://github.com/deviantintegral/symfony · PHP · 128 lines · 108 code · 16 blank · 4 comment · 19 complexity · 313e965f20a3474ad719679a6a7c9686 MD5 · raw file

  1. <?php
  2. use Symfony\Component\Routing\Exception\MethodNotAllowedException;
  3. use Symfony\Component\Routing\Exception\ResourceNotFoundException;
  4. use Symfony\Component\Routing\RequestContext;
  5. /**
  6. * This class has been auto-generated
  7. * by the Symfony Routing Component.
  8. */
  9. class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
  10. {
  11. public function __construct(RequestContext $context)
  12. {
  13. $this->context = $context;
  14. }
  15. public function match($rawPathinfo)
  16. {
  17. $allow = $allowSchemes = array();
  18. $pathinfo = rawurldecode($rawPathinfo);
  19. $context = $this->context;
  20. $requestMethod = $canonicalMethod = $context->getMethod();
  21. if ('HEAD' === $requestMethod) {
  22. $canonicalMethod = 'GET';
  23. }
  24. switch ($pathinfo) {
  25. default:
  26. $routes = array(
  27. '/trailing/simple/no-methods/' => array(array('_route' => 'simple_trailing_slash_no_methods'), null, null, null),
  28. '/trailing/simple/get-method/' => array(array('_route' => 'simple_trailing_slash_GET_method'), null, array('GET' => 0), null),
  29. '/trailing/simple/head-method/' => array(array('_route' => 'simple_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null),
  30. '/trailing/simple/post-method/' => array(array('_route' => 'simple_trailing_slash_POST_method'), null, array('POST' => 0), null),
  31. '/not-trailing/simple/no-methods' => array(array('_route' => 'simple_not_trailing_slash_no_methods'), null, null, null),
  32. '/not-trailing/simple/get-method' => array(array('_route' => 'simple_not_trailing_slash_GET_method'), null, array('GET' => 0), null),
  33. '/not-trailing/simple/head-method' => array(array('_route' => 'simple_not_trailing_slash_HEAD_method'), null, array('HEAD' => 0), null),
  34. '/not-trailing/simple/post-method' => array(array('_route' => 'simple_not_trailing_slash_POST_method'), null, array('POST' => 0), null),
  35. );
  36. if (!isset($routes[$pathinfo])) {
  37. break;
  38. }
  39. list($ret, $requiredHost, $requiredMethods, $requiredSchemes) = $routes[$pathinfo];
  40. $hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
  41. if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
  42. if ($hasRequiredScheme) {
  43. $allow += $requiredMethods;
  44. }
  45. break;
  46. }
  47. if (!$hasRequiredScheme) {
  48. $allowSchemes += $requiredSchemes;
  49. break;
  50. }
  51. return $ret;
  52. }
  53. $matchedPathinfo = $pathinfo;
  54. $regexList = array(
  55. 0 => '{^(?'
  56. .'|/trailing/regex/(?'
  57. .'|no\\-methods/([^/]++)/(*:47)'
  58. .'|get\\-method/([^/]++)/(*:75)'
  59. .'|head\\-method/([^/]++)/(*:104)'
  60. .'|post\\-method/([^/]++)/(*:134)'
  61. .')'
  62. .'|/not\\-trailing/regex/(?'
  63. .'|no\\-methods/([^/]++)(*:187)'
  64. .'|get\\-method/([^/]++)(*:215)'
  65. .'|head\\-method/([^/]++)(*:244)'
  66. .'|post\\-method/([^/]++)(*:273)'
  67. .')'
  68. .')$}sD',
  69. );
  70. foreach ($regexList as $offset => $regex) {
  71. while (preg_match($regex, $matchedPathinfo, $matches)) {
  72. switch ($m = (int) $matches['MARK']) {
  73. default:
  74. $routes = array(
  75. 47 => array(array('_route' => 'regex_trailing_slash_no_methods'), array('param'), null, null),
  76. 75 => array(array('_route' => 'regex_trailing_slash_GET_method'), array('param'), array('GET' => 0), null),
  77. 104 => array(array('_route' => 'regex_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null),
  78. 134 => array(array('_route' => 'regex_trailing_slash_POST_method'), array('param'), array('POST' => 0), null),
  79. 187 => array(array('_route' => 'regex_not_trailing_slash_no_methods'), array('param'), null, null),
  80. 215 => array(array('_route' => 'regex_not_trailing_slash_GET_method'), array('param'), array('GET' => 0), null),
  81. 244 => array(array('_route' => 'regex_not_trailing_slash_HEAD_method'), array('param'), array('HEAD' => 0), null),
  82. 273 => array(array('_route' => 'regex_not_trailing_slash_POST_method'), array('param'), array('POST' => 0), null),
  83. );
  84. list($ret, $vars, $requiredMethods, $requiredSchemes) = $routes[$m];
  85. foreach ($vars as $i => $v) {
  86. if (isset($matches[1 + $i])) {
  87. $ret[$v] = $matches[1 + $i];
  88. }
  89. }
  90. $hasRequiredScheme = !$requiredSchemes || isset($requiredSchemes[$context->getScheme()]);
  91. if ($requiredMethods && !isset($requiredMethods[$canonicalMethod]) && !isset($requiredMethods[$requestMethod])) {
  92. if ($hasRequiredScheme) {
  93. $allow += $requiredMethods;
  94. }
  95. break;
  96. }
  97. if (!$hasRequiredScheme) {
  98. $allowSchemes += $requiredSchemes;
  99. break;
  100. }
  101. return $ret;
  102. }
  103. if (273 === $m) {
  104. break;
  105. }
  106. $regex = substr_replace($regex, 'F', $m - $offset, 1 + strlen($m));
  107. $offset += strlen($m);
  108. }
  109. }
  110. throw $allow ? new MethodNotAllowedException(array_keys($allow)) : new ResourceNotFoundException();
  111. }
  112. }