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

Breadcrumb

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

function Request::prepareBasePath

Prepares the 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 1856

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

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

API Navigation

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