public function StreamWrapperManager::registerWrapper

public StreamWrapperManager::registerWrapper($scheme, $class, $type)

Registers stream wrapper with PHP.

Parameters

string $scheme: The scheme of the stream wrapper.

string $class: The class of the stream wrapper.

int $type: The type of the stream wrapper.

Overrides StreamWrapperManagerInterface::registerWrapper

File

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

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 = array('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;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StreamWrapper!StreamWrapperManager.php/function/StreamWrapperManager::registerWrapper/8.1.x