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

Breadcrumb

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

function Request::preparePathInfo

Prepares the path info.

1 call to Request::preparePathInfo()
Request::getPathInfo in vendor/symfony/http-foundation/Request.php
Returns the path being requested relative to the executed script.

File

vendor/symfony/http-foundation/Request.php, line 1880

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

protected function preparePathInfo() : string {
    if (null === ($requestUri = $this->getRequestUri())) {
        return '/';
    }
    // Remove the query string from REQUEST_URI
    if (false !== ($pos = strpos($requestUri, '?'))) {
        $requestUri = substr($requestUri, 0, $pos);
    }
    if ('' !== $requestUri && '/' !== $requestUri[0]) {
        $requestUri = '/' . $requestUri;
    }
    if (null === ($baseUrl = $this->getBaseUrlReal())) {
        return $requestUri;
    }
    $pathInfo = substr($requestUri, \strlen($baseUrl));
    if ('' === $pathInfo) {
        // If substr() returns false then PATH_INFO is set to an empty string
        return '/';
    }
    return $pathInfo;
}

API Navigation

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