url_matcher3.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. if (0 === strpos($pathinfo, '/rootprefix')) {
  33. // static
  34. if ('/rootprefix/test' === $pathinfo) {
  35. return array('_route' => 'static');
  36. }
  37. // dynamic
  38. if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
  39. return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
  40. }
  41. }
  42. // with-condition
  43. if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) {
  44. return array('_route' => 'with-condition');
  45. }
  46. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  47. }
  48. }