public function ApacheUrlMatcher::match

Tries to match a URL based on Apache mod_rewrite matching.

Returns false if no route matches the URL.

Parameters

string $pathinfo The pathinfo to be parsed:

Return value

array An array of parameters

Throws

MethodNotAllowedException If the current method is not allowed

Overrides UrlMatcher::match

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php, line 34

Class

ApacheUrlMatcher
ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper).

Namespace

Symfony\Component\Routing\Matcher

Code

public function match($pathinfo) {
  $parameters = array();
  $defaults = array();
  $allow = array();
  $match = false;
  foreach ($_SERVER as $key => $value) {
    $name = $key;
    if (0 === strpos($name, 'REDIRECT_')) {
      $name = substr($name, 9);
    }
    if (0 === strpos($name, '_ROUTING_DEFAULTS_')) {
      $name = substr($name, 18);
      $defaults[$name] = $value;
    }
    elseif (0 === strpos($name, '_ROUTING_')) {
      $name = substr($name, 9);
      if ('_route' == $name) {
        $match = true;
        $parameters[$name] = $value;
      }
      elseif (0 === strpos($name, '_allow_')) {
        $allow[] = substr($name, 7);
      }
      else {
        $parameters[$name] = $value;
      }
    }
    else {
      continue;
    }
    unset($_SERVER[$key]);
  }
  if ($match) {
    return $this
      ->mergeDefaults($parameters, $defaults);
  }
  elseif (0 < count($allow)) {
    throw new MethodNotAllowedException($allow);
  }
  else {
    return parent::match($pathinfo);
  }
}