You are here

public function OEmbedStreamWrapper::stream_open in oEmbed 7.0

Same name and namespace in other branches
  1. 7 OEmbedStreamWrapper.inc \OEmbedStreamWrapper::stream_open()

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.).

bitmask $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 StreamWrapperInterface::stream_open

File

./OEmbedStreamWrapper.inc, line 165
Create a oEmbed Stream Wrapper class.

Class

OEmbedStreamWrapper
@file Create a oEmbed Stream Wrapper class.

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;
  }
  $matches = array();
  $provider = oembed_get_provider($this
    ->getExternalUrl(), $matches);
  if ($provider === FALSE) {
    return FALSE;
  }
  if ((bool) $provider && $options & STREAM_USE_PATH) {
    $opened_url = $uri;
  }
  return (bool) $provider;
}