class ApacheUrlMatcher

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

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of ApacheUrlMatcher

1 file declares its use of ApacheUrlMatcher
ApacheUrlMatcherTest.php in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php

File

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

Namespace

Symfony\Component\Routing\Matcher
View source
class ApacheUrlMatcher extends UrlMatcher {

  /**
   * Tries to match a URL based on Apache mod_rewrite matching.
   *
   * Returns false if no route matches the URL.
   *
   * @param string $pathinfo The pathinfo to be parsed
   *
   * @return array An array of parameters
   *
   * @throws MethodNotAllowedException If the current method is not allowed
   */
  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);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ApacheUrlMatcher::match public function Tries to match a URL based on Apache mod_rewrite matching. Overrides UrlMatcher::match
UrlMatcher::$allow protected property
UrlMatcher::$context protected property
UrlMatcher::$routes private property
UrlMatcher::getContext public function Gets the request context. Overrides RequestContextAwareInterface::getContext
UrlMatcher::handleRouteRequirements protected function Handles specific route requirements. 1
UrlMatcher::matchCollection protected function Tries to match a URL with a set of routes. 1
UrlMatcher::mergeDefaults protected function Get merged default parameters.
UrlMatcher::REQUIREMENT_MATCH constant
UrlMatcher::REQUIREMENT_MISMATCH constant
UrlMatcher::ROUTE_MATCH constant
UrlMatcher::setContext public function Sets the request context. Overrides RequestContextAwareInterface::setContext
UrlMatcher::__construct public function Constructor. 3