function LocalStream::getTarget
Same name in other branches
- 8.9.x core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::getTarget()
- 10 core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::getTarget()
- 11.x core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::getTarget()
Returns the local writable target of the resource within the stream.
This function should be used in place of calls to realpath() or similar functions when attempting to determine the location of a file. While functions like realpath() may return the location of a read-only file, this method may return a URI or path suitable for writing that is completely separate from the URI used for reading.
Parameters
string $uri: Optional URI.
Return value
string|bool Returns a string representing a location suitable for writing of a file, or FALSE if unable to write to the file such as with read-only streams.
6 calls to LocalStream::getTarget()
- LocalStream::dirname in core/
lib/ Drupal/ Core/ StreamWrapper/ LocalStream.php - Gets the name of the directory from a given path.
- LocalStream::getLocalPath in core/
lib/ Drupal/ Core/ StreamWrapper/ LocalStream.php - Returns the canonical absolute path of the URI, if possible.
- LocalStream::mkdir in core/
lib/ Drupal/ Core/ StreamWrapper/ LocalStream.php - Create a directory.
- PrivateStream::getExternalUrl in core/
lib/ Drupal/ Core/ StreamWrapper/ PrivateStream.php - Returns a web accessible URL for the resource.
- PublicStream::getExternalUrl in core/
lib/ Drupal/ Core/ StreamWrapper/ PublicStream.php - Returns a web accessible URL for the resource.
File
-
core/
lib/ Drupal/ Core/ StreamWrapper/ LocalStream.php, line 85
Class
- LocalStream
- Defines a Drupal stream wrapper base class for local files.
Namespace
Drupal\Core\StreamWrapperCode
protected function getTarget($uri = NULL) {
if (!isset($uri)) {
$uri = $this->uri;
}
[
,
$target,
] = explode('://', $uri, 2);
// Remove erroneous leading or trailing, forward-slashes and backslashes.
return trim($target, '\\/');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.