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

hook_stream_wrappers_alter()

Return value

Returns the entire Drupal stream wrapper registry.

Related topics

▾ 5 functions call file_get_stream_wrappers()

file_field_settings_form in modules/file/file.field.inc
Implement hook_field_settings_form().
file_stream_wrapper_get_class in includes/file.inc
Returns the stream wrapper class name for a given scheme.
image_field_settings_form in modules/image/image.field.inc
Implement hook_field_settings_form().
system_file_system_settings in modules/system/system.admin.inc
Form builder; Configure the site file handling.
_drupal_bootstrap_full in includes/common.inc

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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.