You are here

protected function Request::prepareBasePath in Zircon Profile 8.0

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

Prepares the base path.

Return value

string base path

1 call to Request::prepareBasePath()
Request::getBasePath in vendor/symfony/http-foundation/Request.php
Returns the root path from which this request is executed.

File

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

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

protected function prepareBasePath() {
  $filename = basename($this->server
    ->get('SCRIPT_FILENAME'));
  $baseUrl = $this
    ->getBaseUrl();
  if (empty($baseUrl)) {
    return '';
  }
  if (basename($baseUrl) === $filename) {
    $basePath = dirname($baseUrl);
  }
  else {
    $basePath = $baseUrl;
  }
  if ('\\' === DIRECTORY_SEPARATOR) {
    $basePath = str_replace('\\', '/', $basePath);
  }
  return rtrim($basePath, '/');
}