You are here

protected function VideoRemoteStreamWrapper::getTarget in Video 8

Same name and namespace in other branches
  1. 8.2 src/StreamWrapper/VideoRemoteStreamWrapper.php \Drupal\video\StreamWrapper\VideoRemoteStreamWrapper::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.

3 calls to VideoRemoteStreamWrapper::getTarget()
VideoRemoteStreamWrapper::dirname in src/StreamWrapper/VideoRemoteStreamWrapper.php
Gets the name of the directory from a given path.
VideoRemoteStreamWrapper::getExternalUrl in src/StreamWrapper/VideoRemoteStreamWrapper.php
Returns a web accessible URL for the resource.
VideoRemoteStreamWrapper::getLocalPath in src/StreamWrapper/VideoRemoteStreamWrapper.php
Returns the canonical absolute path of the URI, if possible.

File

src/StreamWrapper/VideoRemoteStreamWrapper.php, line 81

Class

VideoRemoteStreamWrapper
Defines a video read only stream wrapper class.

Namespace

Drupal\video\StreamWrapper

Code

protected function getTarget($uri = NULL) {
  if (!isset($uri)) {
    $uri = $this->uri;
  }
  list(, $target) = explode('://', $uri, 2);

  // Remove erroneous leading or trailing, forward-slashes and backslashes.
  return trim($target, '\\/');
}