url_matcher3.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 = array();
  18. $pathinfo = rawurldecode($rawPathinfo);
  19. $context = $this->context;
  20. $request = $this->request ?: $this->createRequest($pathinfo);
  21. if (0 === strpos($pathinfo, '/rootprefix')) {
  22. // static
  23. if ('/rootprefix/test' === $pathinfo) {
  24. return array('_route' => 'static');
  25. }
  26. // dynamic
  27. if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
  28. return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
  29. }
  30. }
  31. // with-condition
  32. if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) {
  33. return array('_route' => 'with-condition');
  34. }
  35. throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
  36. }
  37. }