function SessionStreamWrapper::stream_write
Same name and namespace in other branches
- 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_write()
- 8.x-1.x stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_write()
Support for fwrite(), file_put_contents() etc.
Parameters
string $data: The string to be written.
Return value
int The number of bytes written (integer).
Overrides PhpStreamWrapperInterface::stream_write
See also
http://php.net/manual/en/streamwrapper.stream-write.php
File
-
modules/
stream_wrapper_example/ src/ StreamWrapper/ SessionStreamWrapper.php, line 463
Class
- SessionStreamWrapper
- Example stream wrapper class to handle session:// streams.
Namespace
Drupal\stream_wrapper_example\StreamWrapperCode
public function stream_write($data) {
// Sanitize the data in a simple way since we're putting it into the
// session variable.
$data = Html::escape($data);
$this->sessionContent = substr_replace($this->sessionContent, $data, $this->streamPointer);
$this->streamPointer += strlen($data);
return strlen($data);
}