function PublicStream::baseUrl

Same name in other branches
  1. 9 core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::baseUrl()
  2. 8.9.x core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::baseUrl()
  3. 10 core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::baseUrl()

Finds and returns the base URL for public://.

Defaults to the current site's base URL plus directory path.

Note that this static method is used by \Drupal\system\Form\FileSystemForm so you should alter that form or substitute a different form if you change the class providing the stream_wrapper.public service.

Return value

string The external base URL for public://

3 calls to PublicStream::baseUrl()
AssetsStream::baseUrl in core/lib/Drupal/Core/StreamWrapper/AssetsStream.php
Finds and returns the base URL for public://.
FileSystemForm::buildForm in core/modules/system/src/Form/FileSystemForm.php
Form constructor.
PublicStream::getExternalUrl in core/lib/Drupal/Core/StreamWrapper/PublicStream.php
Returns a web accessible URL for the resource.
1 method overrides PublicStream::baseUrl()
AssetsStream::baseUrl in core/lib/Drupal/Core/StreamWrapper/AssetsStream.php
Finds and returns the base URL for public://.

File

core/lib/Drupal/Core/StreamWrapper/PublicStream.php, line 66

Class

PublicStream
Defines a Drupal public (public://) stream wrapper class.

Namespace

Drupal\Core\StreamWrapper

Code

public static function baseUrl() {
    $settings_base_url = Settings::get('file_public_base_url', '');
    if ($settings_base_url) {
        return (string) $settings_base_url;
    }
    else {
        return $GLOBALS['base_url'] . '/' . static::basePath();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.