public function SessionStreamWrapper::stream_flush in Examples for Developers 3.x
Same name and namespace in other branches
- 8 stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_flush()
Flushes the output.
This method is called in response to fflush() and when the stream is being closed while any un-flushed data has been written to it before. If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.
Note, if not implemented, FALSE is assumed as the return value.
Return value
bool Should return TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
Overrides PhpStreamWrapperInterface::stream_flush
See also
fflush()
http://php.net/manual/en/streamwrapper.stream-flush.php
File
- modules/
stream_wrapper_example/ src/ StreamWrapper/ SessionStreamWrapper.php, line 536
Class
- SessionStreamWrapper
- Example stream wrapper class to handle session:// streams.
Namespace
Drupal\stream_wrapper_example\StreamWrapperCode
public function stream_flush() {
// @codingStandardsIgnoreEnd
if ($this->streamMode == 'w') {
// Since we aren't writing directly to the session, we need to send
// the bytes on to the store.
$path = $this
->getLocalPath($this->uri);
$this->sessionHelper
->setPath($path, $this->sessionContent);
$this->sessionContent = '';
$this->streamPointer = 0;
}
return TRUE;
}