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

Breadcrumb

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

function RequestContext::fromUri

File

vendor/symfony/routing/RequestContext.php, line 48

Class

RequestContext
Holds information about the current request.

Namespace

Symfony\Component\Routing

Code

public static function fromUri(string $uri, string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443) : self {
    if (false !== ($i = strpos($uri, '\\')) && $i < strcspn($uri, '?#')) {
        $uri = '';
    }
    if ('' !== $uri && (\ord($uri[0]) <= 32 || \ord($uri[-1]) <= 32 || \strlen($uri) !== strcspn($uri, "\r\n\t"))) {
        $uri = '';
    }
    $uri = parse_url($uri);
    $scheme = $uri['scheme'] ?? $scheme;
    $host = $uri['host'] ?? $host;
    if (isset($uri['port'])) {
        if ('http' === $scheme) {
            $httpPort = $uri['port'];
        }
        elseif ('https' === $scheme) {
            $httpsPort = $uri['port'];
        }
    }
    return new self($uri['path'] ?? '', 'GET', $host, $scheme, $httpPort, $httpsPort);
}

API Navigation

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