You are here

public function oEmbedStream::stream_open in oEmbed 8

Support for fopen(), file_get_contents(), file_put_contents() etc.

Parameters

string $uri: A string containing the path to the file to open.

string $mode: The file mode ("r", "wb" etc.).

int $options: A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.

string &$opened_url: A string containing the path actually opened.

Return value

bool TRUE if file was opened successfully.

Overrides ReadOnlyStream::stream_open

File

src/StreamWrapper/oEmbedStream.php, line 131
Create a oEmbed Stream Wrapper class.

Class

oEmbedStream
@file Create a oEmbed Stream Wrapper class.

Namespace

Drupal\oembed\StreamWrapper

Code

public function stream_open($uri, $mode, $options, &$opened_url) {
  $this
    ->setUri($uri);

  // We only handle Read-Only mode by default.
  if ($mode != 'r' && $mode != 'rb') {
    return FALSE;
  }
  $provider = \Drupal::service('oembed.provider.delegating')
    ->supports($this
    ->getExternalUrl());
  if ($provider === FALSE) {
    return FALSE;
  }
  if ((bool) $provider && $options & STREAM_USE_PATH) {
    $opened_url = $uri;
  }
  return (bool) $provider;
}