function SessionStreamWrapper::stream_open
Same name in other branches
- 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_open()
- 8.x-1.x stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_open()
Overrides PhpStreamWrapperInterface::stream_open
File
-
modules/
stream_wrapper_example/ src/ StreamWrapper/ SessionStreamWrapper.php, line 266
Class
- SessionStreamWrapper
- Example stream wrapper class to handle session:// streams.
Namespace
Drupal\stream_wrapper_example\StreamWrapperCode
public function stream_open($uri, $mode, $options, &$opened_path) {
// @codingStandardsIgnoreEnd
$this->uri = $uri;
$path = $this->getLocalPath($uri);
// We will support two modes only, 'r' and 'w'. If the key is 'r',
// check to make sure the file is there.
if (stristr($mode, 'r') !== FALSE) {
if (!$this->sessionHelper
->checkPath($path)) {
return FALSE;
}
else {
$buffer = $this->sessionHelper
->getPath($path);
if (!is_string($buffer)) {
return FALSE;
}
$this->sessionContent = $buffer;
}
$this->streamMode = 'r';
}
else {
$this->sessionContent = '';
$this->streamMode = 'w';
}
// Reset the stream pointer since this is an open.
$this->streamPointer = 0;
return TRUE;
}