StreamWrapperManagerInterface
interface StreamWrapperManagerInterface (View source)
Provides a StreamWrapper manager.
Methods
Provides Drupal stream wrapper registry.
Returns registered stream wrapper names.
Returns registered stream wrapper descriptions.
Returns a reference to the stream wrapper class responsible for a scheme.
Returns a reference to the stream wrapper class responsible for a URI.
Returns the stream wrapper class name for a given scheme.
Registers stream wrapper with PHP.
Returns the part of a URI after the schema.
Normalizes a URI by making it syntactically correct.
Returns the scheme of a URI (e.g. a stream).
Checks that the scheme of a stream URI is valid.
Determines whether the URI has a valid scheme for file API operations.
Details
array
getWrappers(int $filter = StreamWrapperInterface::ALL)
Provides Drupal stream wrapper registry.
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.
Provide a facility for managing and querying user-defined stream wrappers in PHP. PHP's internal stream_get_wrappers() doesn't return the class registered to handle a stream, which we need to be able to find the handler for class instantiation.
If a module registers a scheme that is already registered with PHP, the existing scheme will be unregistered and replaced with the specified class.
A stream is referenced as "scheme://target".
The optional $filter parameter can be used to retrieve only the stream wrappers that are appropriate for particular usage. For example, this returns only stream wrappers that use local file storage:
array
getNames(int $filter = StreamWrapperInterface::ALL)
Returns registered stream wrapper names.
array
getDescriptions(int $filter = StreamWrapperInterface::ALL)
Returns registered stream wrapper descriptions.
StreamWrapperInterface|bool
getViaScheme(string $scheme)
Returns a reference to the stream wrapper class responsible for a scheme.
This helper method returns a stream instance using a scheme. That is, the passed string does not contain a "://". For example, "public" is a scheme but "public://" is a URI (stream). This is because the later contains both a scheme and target despite target being empty.
Note: the instance URI will be initialized to "scheme://" so that you can make the customary method calls as if you had retrieved an instance by URI.
StreamWrapperInterface|bool
getViaUri(string $uri)
Returns a reference to the stream wrapper class responsible for a URI.
The scheme determines the stream wrapper class that should be used by consulting the stream wrapper registry.
string|bool
getClass(string $scheme)
Returns the stream wrapper class name for a given scheme.
registerWrapper(string $scheme, string $class, int $type)
Registers stream wrapper with PHP.
static string|bool
getTarget(string $uri)
Returns the part of a URI after the schema.
string
normalizeUri(string $uri)
Normalizes a URI by making it syntactically correct.
A stream is referenced as "scheme://target".
The following actions are taken:
- Remove trailing slashes from target
- Trim erroneous leading slashes from target. e.g. ":///" becomes "://".
static string|bool
getScheme(string $uri)
Returns the scheme of a URI (e.g. a stream).
bool
isValidScheme(string $scheme)
Checks that the scheme of a stream URI is valid.
Confirms that there is a registered stream handler for the provided scheme and that it is callable. This is useful if you want to confirm a valid scheme without creating a new instance of the registered handler.
bool
isValidUri(string $uri)
Determines whether the URI has a valid scheme for file API operations.
There must be a scheme and it must be a Drupal-provided scheme like 'public', 'private', 'temporary', or an extension provided with hook_stream_wrappers().