function StreamWrapperManager::registerWrapper

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::registerWrapper()
  2. 8.9.x core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::registerWrapper()
  3. 11.x core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::registerWrapper()
1 call to StreamWrapperManager::registerWrapper()
StreamWrapperManager::register in core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php
Registers the tagged stream wrappers.

File

core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php, line 198

Class

StreamWrapperManager
Provides a StreamWrapper manager.

Namespace

Drupal\Core\StreamWrapper

Code

public function registerWrapper($scheme, $class, $type) {
    if (in_array($scheme, stream_get_wrappers(), TRUE)) {
        stream_wrapper_unregister($scheme);
    }
    if (($type & StreamWrapperInterface::LOCAL) == StreamWrapperInterface::LOCAL) {
        stream_wrapper_register($scheme, $class);
    }
    else {
        stream_wrapper_register($scheme, $class, STREAM_IS_URL);
    }
    // Pre-populate the static cache with the filters most typically used.
    $info = [
        'type' => $type,
        'class' => $class,
    ];
    $this->wrappers[StreamWrapperInterface::ALL][$scheme] = $info;
    if (($type & StreamWrapperInterface::WRITE_VISIBLE) == StreamWrapperInterface::WRITE_VISIBLE) {
        $this->wrappers[StreamWrapperInterface::WRITE_VISIBLE][$scheme] = $info;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.