function SessionStreamWrapper::dirname
Same name in other branches
- 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::dirname()
- 8.x-1.x stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::dirname()
Gets the name of the directory from a given path.
Parameters
string $uri: A URI.
Return value
string A string containing the directory name.
Overrides StreamWrapperInterface::dirname
See also
drupal_dirname()
File
-
modules/
stream_wrapper_example/ src/ StreamWrapper/ SessionStreamWrapper.php, line 658
Class
- SessionStreamWrapper
- Example stream wrapper class to handle session:// streams.
Namespace
Drupal\stream_wrapper_example\StreamWrapperCode
public function dirname($uri = NULL) {
[
$scheme,
] = explode('://', $uri, 2);
$target = $this->getLocalPath($uri);
if (strpos($target, '/')) {
$dirname = preg_replace('@/[^/]*$@', '', $target);
}
else {
$dirname = '';
}
return $scheme . '://' . $dirname;
}