function PublicStream::getLocalPath

Same name in other branches
  1. 9 core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::getLocalPath()
  2. 11.x core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::getLocalPath()

Overrides LocalStream::getLocalPath

File

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

Class

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

Namespace

Drupal\Core\StreamWrapper

Code

protected function getLocalPath($uri = NULL) {
    $path = parent::getLocalPath($uri);
    if (!$path || str_starts_with($path, 'vfs://')) {
        return $path;
    }
    if (Settings::get('sa_core_2022_012_override') === TRUE) {
        return $path;
    }
    $private_path = Settings::get('file_private_path');
    if ($private_path) {
        $private_path = realpath($private_path);
        if ($private_path && str_starts_with($path, $private_path)) {
            return FALSE;
        }
    }
    return $path;
}

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