file_get_stream_wrappers
- Versions
- 7
file_get_stream_wrappers()
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".
see hook_stream_wrappers()
See also
Return value
Returns the entire Drupal stream wrapper registry.
Related topics
Code
includes/file.inc, line 94
<?php
function file_get_stream_wrappers() {
$wrappers = &drupal_static(__FUNCTION__);
if (!isset($wrappers)) {
$wrappers = module_invoke_all('stream_wrappers');
drupal_alter('stream_wrappers', $wrappers);
$existing = stream_get_wrappers();
foreach ($wrappers as $scheme => $info) {
// We only register classes that implement our interface.
if (in_array('DrupalStreamWrapperInterface', class_implements($info['class']), TRUE)) {
// Record whether we are overriding an existing scheme.
if (in_array($scheme, $existing, TRUE)) {
$wrappers[$scheme]['override'] = TRUE;
stream_wrapper_unregister($scheme);
}
else {
$wrappers[$scheme]['override'] = FALSE;
}
stream_wrapper_register($scheme, $info['class']);
}
}
}
return $wrappers;
}
?>Login or register to post comments 