You are here

public function LocalReadOnlyStream::stream_open in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php \Drupal\Core\StreamWrapper\LocalReadOnlyStream::stream_open()
  2. 10 core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php \Drupal\Core\StreamWrapper\LocalReadOnlyStream::stream_open()

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

Parameters

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

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

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

string $opened_path: A string containing the path actually opened.

Return value

bool Returns TRUE if file was opened successfully.

Overrides LocalStream::stream_open

See also

http://php.net/manual/streamwrapper.stream-open.php

File

core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php, line 28

Class

LocalReadOnlyStream
Defines a read-only Drupal stream wrapper base class for local files.

Namespace

Drupal\Core\StreamWrapper

Code

public function stream_open($uri, $mode, $options, &$opened_path) {
  if (!in_array($mode, [
    'r',
    'rb',
    'rt',
  ])) {
    if ($options & STREAM_REPORT_ERRORS) {
      trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING);
    }
    return FALSE;
  }
  return parent::stream_open($uri, $mode, $options, $opened_path);
}