3 namespace Drupal\Core\StreamWrapper;
6 * Defines a Drupal stream wrapper extension.
8 * Provides a Drupal interface and classes to implement PHP stream wrappers for
9 * public, private, and temporary files. Extends the PhpStreamWrapperInterface
10 * with methods expected by Drupal stream wrapper classes.
12 * A stream wrapper is an abstraction of a file system that allows Drupal to
13 * use the same set of methods to access both local files and remote resources.
15 * Note that PHP 5.2 fopen() only supports URIs of the form "scheme://target"
16 * despite the fact that according to RFC 3986 a URI's scheme component
17 * delimiter is in general just ":", not "://". Because of this PHP limitation
18 * and for consistency Drupal will only accept URIs of form "scheme://target".
20 * @see http://www.faqs.org/rfcs/rfc3986.html
21 * @see http://bugs.php.net/bug.php?id=47070
23 interface StreamWrapperInterface extends PhpStreamWrapperInterface {
26 * Stream wrapper bit flags that are the basis for composite types.
28 * Note that 0x0002 is skipped, because it was the value of a constant that
29 * has since been removed.
33 * A filter that matches all wrappers.
38 * Refers to a local file system location.
43 * Wrapper is readable (almost always true).
48 * Wrapper is writeable.
53 * Exposed in the UI and potentially web accessible.
55 const VISIBLE = 0x0010;
58 * Composite stream wrapper bit flags that are usually used as the types.
62 * Defines the stream wrapper bit flag for a hidden file.
64 * This is not visible in the UI or accessible via web, but readable and
65 * writable; for instance, the temporary directory for file uploads.
67 const HIDDEN = 0x000C;
70 * Hidden, readable and writeable using local files.
72 const LOCAL_HIDDEN = 0x000D;
75 * Visible, readable and writeable.
77 const WRITE_VISIBLE = 0x001C;
80 * Visible and read-only.
82 const READ_VISIBLE = 0x0014;
85 * This is the default 'type' flag. This does not include
86 * StreamWrapperInterface::LOCAL, because PHP grants a greater trust level to
87 * local files (for example, they can be used in an "include" statement,
88 * regardless of the "allow_url_include" setting), so stream wrappers need to
89 * explicitly opt-in to this.
91 const NORMAL = 0x001C;
94 * Visible, readable and writeable using local files.
96 const LOCAL_NORMAL = 0x001D;
99 * Returns the type of stream wrapper.
103 public static function getType();
106 * Returns the name of the stream wrapper for use in the UI.
109 * The stream wrapper name.
111 public function getName();
114 * Returns the description of the stream wrapper for use in the UI.
117 * The stream wrapper description.
119 public function getDescription();
122 * Sets the absolute stream resource URI.
124 * This allows you to set the URI. Generally is only called by the factory
128 * A string containing the URI that should be used for this instance.
130 public function setUri($uri);
133 * Returns the stream resource URI.
136 * Returns the current URI of the instance.
138 public function getUri();
141 * Returns a web accessible URL for the resource.
143 * This function should return a URL that can be embedded in a web page
144 * and accessed from a browser. For example, the external URL of
145 * "youtube://xIpLd0WQKCY" might be
146 * "http://www.youtube.com/watch?v=xIpLd0WQKCY".
149 * Returns a string containing a web accessible URL for the resource.
151 public function getExternalUrl();
154 * Returns canonical, absolute path of the resource.
156 * Implementation placeholder. PHP's realpath() does not support stream
157 * wrappers. We provide this as a default so that individual wrappers may
158 * implement their own solutions.
161 * Returns a string with absolute pathname on success (implemented
162 * by core wrappers), or FALSE on failure or if the registered
163 * wrapper does not provide an implementation.
165 public function realpath();
168 * Gets the name of the directory from a given path.
170 * This method is usually accessed through drupal_dirname(), which wraps
171 * around the normal PHP dirname() function, which does not support stream
178 * A string containing the directory name, or FALSE if not applicable.
180 * @see drupal_dirname()
182 public function dirname($uri = NULL);