function SessionStreamWrapper::stream_flush

Same name and namespace in other branches
  1. 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_flush()
  2. 8.x-1.x stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_flush()

Support for fflush().

Return value

bool TRUE if data was successfully stored (or there was no data to store). This always returns TRUE, as this example provides and needs no flush support.

Overrides PhpStreamWrapperInterface::stream_flush

See also

http://php.net/manual/en/streamwrapper.stream-flush.php

File

modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php, line 515

Class

SessionStreamWrapper
Example stream wrapper class to handle session:// streams.

Namespace

Drupal\stream_wrapper_example\StreamWrapper

Code

public function stream_flush() {
  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;
}