You are here

public function StreamWrapperManager::registerWrapper in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::registerWrapper()

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

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 192
Contains \Drupal\Core\StreamWrapper\StreamWrapperManager.

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;
  }
}