abstract class RedirectableUrlMatcher

Same name in this branch

@author Fabien Potencier <fabien@symfony.com>

@api

Hierarchy

Expanded class hierarchy of RedirectableUrlMatcher

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php, line 22

Namespace

Symfony\Component\Routing\Matcher
View source
abstract class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface {

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritDoc}
   */
  protected function handleRouteRequirements($pathinfo, $name, Route $route) {

    // check HTTP scheme requirement
    $scheme = $route
      ->getRequirement('_scheme');
    if ($scheme && $this->context
      ->getScheme() !== $scheme) {
      return array(
        self::ROUTE_MATCH,
        $this
          ->redirect($pathinfo, $name, $scheme),
      );
    }
    return array(
      self::REQUIREMENT_MATCH,
      null,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RedirectableUrlMatcher::handleRouteRequirements protected function Handles specific route requirements. Overrides UrlMatcher::handleRouteRequirements
RedirectableUrlMatcher::match public function Tries to match a URL path with a set of routes. Overrides UrlMatcher::match
RedirectableUrlMatcherInterface::redirect public function Redirects the user to another URL. 1
UrlMatcher::$allow protected property
UrlMatcher::$context protected property
UrlMatcher::$routes protected property
UrlMatcher::getAttributes protected function Returns an array of values to use as request attributes. 1
UrlMatcher::getContext public function Gets the request context. Overrides RequestContextAwareInterface::getContext
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. 4