url_matcher3.php 1.7 KB

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