You are here

protected function Request::preparePathInfo in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Request.php \Symfony\Component\HttpFoundation\Request::preparePathInfo()

Prepares the path info.

Return value

string 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 1814

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

protected function preparePathInfo() {
  $baseUrl = $this
    ->getBaseUrl();
  if (null === ($requestUri = $this
    ->getRequestUri())) {
    return '/';
  }
  $pathInfo = '/';

  // Remove the query string from REQUEST_URI
  if ($pos = strpos($requestUri, '?')) {
    $requestUri = substr($requestUri, 0, $pos);
  }
  $pathInfo = substr($requestUri, strlen($baseUrl));
  if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) {

    // If substr() returns false then PATH_INFO is set to an empty string
    return '/';
  }
  elseif (null === $baseUrl) {
    return $requestUri;
  }
  return (string) $pathInfo;
}