function AssetsStream::baseUrl

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/StreamWrapper/AssetsStream.php \Drupal\Core\StreamWrapper\AssetsStream::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://

Overrides PublicStream::baseUrl

File

core/lib/Drupal/Core/StreamWrapper/AssetsStream.php, line 51

Class

AssetsStream
Defines a Drupal stream wrapper class for optimized assets (assets://).

Namespace

Drupal\Core\StreamWrapper

Code

public static function baseUrl() : string {
    $public_path = Settings::get('file_public_path', 'sites/default/files');
    $path = Settings::get('file_assets_path', $public_path);
    if ($path === $public_path) {
        $base_url = PublicStream::baseUrl();
    }
    else {
        $base_url = $GLOBALS['base_url'] . '/' . $path;
    }
    return $base_url;
}

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