You are here

public function RedirectableUrlMatcher::match in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Matcher/RedirectableUrlMatcher.php \Symfony\Component\Routing\Matcher\RedirectableUrlMatcher::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/Matcher/RedirectableUrlMatcher.php, line 25

Class

RedirectableUrlMatcher
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\Routing\Matcher

Code

public function match($pathinfo) {
  try {
    $parameters = parent::match($pathinfo);
  } catch (ResourceNotFoundException $e) {
    if ('/' === substr($pathinfo, -1) || !in_array($this->context
      ->getMethod(), array(
      'HEAD',
      'GET',
    ))) {
      throw $e;
    }
    try {
      parent::match($pathinfo . '/');
      return $this
        ->redirect($pathinfo . '/', null);
    } catch (ResourceNotFoundException $e2) {
      throw $e;
    }
  }
  return $parameters;
}