LocalStream::dirname

public LocalStream::dirname($uri = NULL)

Gets the name of the directory from a given path.

This method is usually accessed through drupal_dirname(), which wraps around the PHP dirname() function because it does not support stream wrappers.

Parameters

string $uri: A URI or path.

Return value

string A string containing the directory name.

Overrides StreamWrapperInterface::dirname

See also

drupal_dirname()

File

core/lib/Drupal/Core/StreamWrapper/LocalStream.php, line 412

Class

LocalStream
Defines a Drupal stream wrapper base class for local files.

Namespace

Drupal\Core\StreamWrapper

Code

1
2
3
4
5
6
7
8
9
10
11
public function dirname($uri = NULL) {
  list($scheme) = explode('://', $uri, 2);
  $target = $this->getTarget($uri);
  $dirname = dirname($target);
 
  if ($dirname == '.') {
    $dirname = '';
  }
 
  return $scheme . '://' . $dirname;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.