StreamWrapperInterface
interface StreamWrapperInterface implements PhpStreamWrapperInterface (View source)
Defines a Drupal stream wrapper extension.
Provides a Drupal interface and classes to implement PHP stream wrappers for public, private, and temporary files. Extends the PhpStreamWrapperInterface with methods expected by Drupal stream wrapper classes.
A stream wrapper is an abstraction of a file system that allows Drupal to use the same set of methods to access both local files and remote resources.
Note that PHP 5.2 fopen() only supports URIs of the form "scheme://target" despite the fact that according to RFC 3986 a URI's scheme component delimiter is in general just ":", not "://". Because of this PHP limitation and for consistency Drupal will only accept URIs of form "scheme://target".
Constants
| ALL |
A filter that matches all wrappers. |
| LOCAL |
Refers to a local file system location. |
| READ |
Wrapper is readable (almost always true). |
| WRITE |
Wrapper is writable. |
| VISIBLE |
Exposed in the UI and potentially web accessible. |
| HIDDEN |
Defines the stream wrapper bit flag for a hidden file. This is not visible in the UI or accessible via web, but readable and writable; for instance, the temporary directory for file uploads. |
| LOCAL_HIDDEN |
Hidden, readable and writable using local files. |
| WRITE_VISIBLE |
Visible, readable and writable. |
| READ_VISIBLE |
Visible and read-only. |
| NORMAL |
This is the default 'type' flag. This does not include
StreamWrapperInterface::LOCAL, because PHP grants a greater trust level to
local files (for example, they can be used in an "include" statement,
regardless of the "allow_url_include" setting), so stream wrappers need to
explicitly opt-in to this. |
| LOCAL_NORMAL |
Visible, readable and writable using local files. |
Methods
Retrieve the underlying stream resource.
Sets metadata on the stream.
No description
Seeks to specific location in a stream.
Change stream options.
Returns the type of stream wrapper.
Returns the name of the stream wrapper for use in the UI.
Returns the description of the stream wrapper for use in the UI.
Sets the absolute stream resource URI.
Returns the stream resource URI.
Returns a web accessible URL for the resource.
Returns canonical, absolute path of the resource.
Gets the name of the directory from a given path.
Details
bool
dir_closedir()
No description
bool
dir_opendir($path, $options)
No description
string
dir_readdir()
No description
bool
dir_rewinddir()
No description
bool
mkdir($path, $mode, $options)
No description
bool
rename($path_from, $path_to)
No description
bool
rmdir($path, $options)
No description
resource|false
stream_cast(int $cast_as)
Retrieve the underlying stream resource.
This method is called in response to stream_select().
stream_close()
Closes stream.
bool
stream_eof()
No description
bool
stream_flush()
No description
bool
stream_lock($operation)
No description
bool
stream_metadata(string $path, int $option, mixed $value)
Sets metadata on the stream.
bool
stream_open($path, $mode, $options, $opened_path)
No description
string
stream_read($count)
No description
bool
stream_seek(int $offset, int $whence = SEEK_SET)
Seeks to specific location in a stream.
This method is called in response to fseek().
The read/write position of the stream should be updated according to the offset and whence.
bool
stream_set_option(int $option, int $arg1, int $arg2)
Change stream options.
This method is called to set options on the stream.
array
stream_stat()
No description
int
stream_tell()
No description
bool
stream_truncate(int $new_size)
Truncate stream.
Will respond to truncation; e.g., through ftruncate().
int
stream_write($data)
No description
bool
unlink($path)
No description
array
url_stat($path, $flags)
No description
static int
getType()
Returns the type of stream wrapper.
string
getName()
Returns the name of the stream wrapper for use in the UI.
string
getDescription()
Returns the description of the stream wrapper for use in the UI.
setUri(string $uri)
Sets the absolute stream resource URI.
This allows you to set the URI. Generally is only called by the factory method.
string
getUri()
Returns the stream resource URI.
string
getExternalUrl()
Returns a web accessible URL for the resource.
This function should return a URL that can be embedded in a web page and accessed from a browser. For example, the external URL of "youtube://xIpLd0WQKCY" might be "http://www.youtube.com/watch?v=xIpLd0WQKCY".
string
realpath()
Returns canonical, absolute path of the resource.
Implementation placeholder. PHP's realpath() does not support stream wrappers. We provide this as a default so that individual wrappers may implement their own solutions.
string
dirname(string $uri = NULL)
Gets the name of the directory from a given path.
This method is usually accessed through \Drupal\Core\File\FileSystemInterface::dirname(), which wraps around the normal PHP dirname() function, which does not support stream wrappers.