You are here

protected function ExtensionStreamBase::getTarget in System stream wrapper 8

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 Returns a string representing a location suitable for writing of a file.

Throws

\InvalidArgumentException If a malformed $uri parameter is passed in.

Overrides LocalStreamTrait::getTarget

2 calls to ExtensionStreamBase::getTarget()
ExtensionStreamBase::dirname in src/StreamWrapper/ExtensionStreamBase.php
Gets the name of the directory from a given path.
ExtensionStreamBase::getExternalUrl in src/StreamWrapper/ExtensionStreamBase.php
Returns a web accessible URL for the resource.

File

src/StreamWrapper/ExtensionStreamBase.php, line 54

Class

ExtensionStreamBase
Defines a base stream wrapper implementation.

Namespace

Drupal\system_stream_wrapper\StreamWrapper

Code

protected function getTarget($uri = NULL) {
  if ($target = strstr(parent::getTarget($uri), '/')) {
    return trim($target, '/');
  }
  return '';
}