function PublicStream::getLocalPath
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::getLocalPath()
- 11.x core/lib/Drupal/Core/StreamWrapper/PublicStream.php \Drupal\Core\StreamWrapper\PublicStream::getLocalPath()
Returns the canonical absolute path of the URI, if possible.
Parameters
string $uri: (optional) The stream wrapper URI to be converted to a canonical absolute path. This may point to a directory or another type of file.
Return value
string|bool If $uri is not set, returns the canonical absolute path of the URI previously set by the Drupal\Core\StreamWrapper\StreamWrapperInterface::setUri() function. If $uri is set and valid for this class, returns its canonical absolute path, as determined by the realpath() function. If $uri is set but not valid, returns FALSE.
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\StreamWrapperCode
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.