public function SessionStreamWrapper::stream_read in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_read()
Return value
string
Overrides PhpStreamWrapperInterface::stream_read
File
- stream_wrapper_example/
src/ StreamWrapper/ SessionStreamWrapper.php, line 452
Class
- SessionStreamWrapper
- Example stream wrapper class to handle session:// streams.
Namespace
Drupal\stream_wrapper_example\StreamWrapperCode
public function stream_read($count) {
// @codingStandardsIgnoreEnd
if (is_string($this->sessionContent)) {
$remaining_chars = strlen($this->sessionContent) - $this->streamPointer;
$number_to_read = min($count, $remaining_chars);
if ($remaining_chars > 0) {
$buffer = substr($this->sessionContent, $this->streamPointer, $number_to_read);
$this->streamPointer += $number_to_read;
return $buffer;
}
}
return FALSE;
}