You are here

public function LocalStreamTrait::dirname in System stream wrapper 8

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.

See also

drupal_dirname()

1 method overrides LocalStreamTrait::dirname()
ExtensionStreamBase::dirname in src/StreamWrapper/ExtensionStreamBase.php
Gets the name of the directory from a given path.

File

src/StreamWrapper/LocalStreamTrait.php, line 30
Contains \Drupal\Core\StreamWrapper\LocalStreamTrait.

Class

LocalStreamTrait
Provides common methods for local streams.

Namespace

Drupal\system_stream_wrapper\StreamWrapper

Code

public function dirname($uri = NULL) {
  if (!isset($uri)) {
    $uri = $this->uri;
  }
  list($scheme) = explode('://', $uri, 2);
  $dirname = dirname($this
    ->getTarget($uri));
  return $dirname !== '.' ? "{$scheme}://{$dirname}" : "{$scheme}://";
}