You are here

public function ProjectUrlMatcher::match in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php \ProjectUrlMatcher::match()
  2. 8.0 vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php \ProjectUrlMatcher::match()
  3. 8.0 vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php \ProjectUrlMatcher::match()
Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php \ProjectUrlMatcher::match()
  2. 8 vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php \ProjectUrlMatcher::match()
  3. 8 vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php \ProjectUrlMatcher::match()

Tries to match a URL path with a set of routes.

If the matcher can not find information, it must throw one of the exceptions documented below.

Parameters

string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded):

Return value

array An array of parameters

Throws

ResourceNotFoundException If the resource could not be found

MethodNotAllowedException If the resource was found but the request method is not allowed

Overrides UrlMatcher::match

File

vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php, line 23

Class

ProjectUrlMatcher
ProjectUrlMatcher.

Code

public function match($pathinfo) {
  $allow = array();
  $pathinfo = rawurldecode($pathinfo);
  $context = $this->context;
  $request = $this->request;
  if (0 === strpos($pathinfo, '/rootprefix')) {

    // static
    if ($pathinfo === '/rootprefix/test') {
      return array(
        '_route' => 'static',
      );
    }

    // dynamic
    if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
      return $this
        ->mergeDefaults(array_replace($matches, array(
        '_route' => 'dynamic',
      )), array());
    }
  }

  // with-condition
  if ($pathinfo === '/with-condition' && $context
    ->getMethod() == "GET") {
    return array(
      '_route' => 'with-condition',
    );
  }
  throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
}