Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CompiledUrlMatcherTrait.php

function CompiledUrlMatcherTrait::match

File

vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherTrait.php, line 35

Class

CompiledUrlMatcherTrait
@author Nicolas Grekas <p@tchwork.com>

Namespace

Symfony\Component\Routing\Matcher\Dumper

Code

public function match(string $pathinfo) : array {
    $allow = $allowSchemes = [];
    if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
        return $ret;
    }
    if ($allow) {
        throw new MethodNotAllowedException(array_keys($allow));
    }
    if (!$this instanceof RedirectableUrlMatcherInterface) {
        throw new ResourceNotFoundException(\sprintf('No routes found for "%s".', $pathinfo));
    }
    if (!\in_array($this->context
        ->getMethod(), [
        'HEAD',
        'GET',
    ], true)) {
        // no-op
    }
    elseif ($allowSchemes) {
        redirect_scheme:
        $scheme = $this->context
            ->getScheme();
        $this->context
            ->setScheme(key($allowSchemes));
        try {
            if ($ret = $this->doMatch($pathinfo)) {
                return $this->redirect($pathinfo, $ret['_route'], $this->context
                    ->getScheme()) + $ret;
            }
        } finally {
            $this->context
                ->setScheme($scheme);
        }
    }
    elseif ('/' !== ($trimmedPathinfo = rtrim($pathinfo, '/') ?: '/')) {
        $pathinfo = $trimmedPathinfo === $pathinfo ? $pathinfo . '/' : $trimmedPathinfo;
        if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
            return $this->redirect($pathinfo, $ret['_route']) + $ret;
        }
        if ($allowSchemes) {
            goto redirect_scheme;
        }
    }
    throw new ResourceNotFoundException(\sprintf('No routes found for "%s".', $pathinfo));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal