url_matcher3.php 1.4 KB

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