菜谱项目

url_matcher3.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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($pathinfo)
  16. {
  17. $allow = array();
  18. $pathinfo = rawurldecode($pathinfo);
  19. $trimmedPathinfo = rtrim($pathinfo, '/');
  20. $context = $this->context;
  21. $request = $this->request;
  22. $requestMethod = $canonicalMethod = $context->getMethod();
  23. $scheme = $context->getScheme();
  24. if ('HEAD' === $requestMethod) {
  25. $canonicalMethod = 'GET';
  26. }
  27. if (0 === strpos($pathinfo, '/rootprefix')) {
  28. // static
  29. if ('/rootprefix/test' === $pathinfo) {
  30. return array('_route' => 'static');
  31. }
  32. // dynamic
  33. if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
  34. return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
  35. }
  36. }
  37. // with-condition
  38. if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) {
  39. return array('_route' => 'with-condition');
  40. }
  41. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  42. }
  43. }