Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401]

(no description)

File Size: 323 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

ReadableStream:: (12 methods):
  __construct()
  __debugInfo()
  close()
  getFile()
  getSize()
  isEOF()
  readBytes()
  seek()
  tell()
  initBufferFromCurrentChunk()
  initBufferFromNextChunk()
  initChunksIterator()


Class: ReadableStream  - X-Ref

ReadableStream abstracts the process of reading a GridFS file.

__construct(CollectionWrapper $collectionWrapper, stdClass $file)   X-Ref
Constructs a readable GridFS stream.

param: CollectionWrapper $collectionWrapper GridFS collection wrapper
param: stdClass          $file              GridFS file document

__debugInfo()   X-Ref
Return internal properties for debugging purposes.

return: array

close()   X-Ref
No description

getFile()   X-Ref
Return the stream's file document.

return: stdClass

getSize()   X-Ref
Return the stream's size in bytes.

return: integer

isEOF()   X-Ref
Return whether the current read position is at the end of the stream.

return: boolean

readBytes($length)   X-Ref
Read bytes from the stream.

Note: this method may return a string smaller than the requested length
if data is not available to be read.

return: string
param: integer $length Number of bytes to read

seek($offset)   X-Ref
Seeks the chunk and buffer offsets for the next read operation.

param: integer $offset

tell()   X-Ref
Return the current position of the stream.

This is the offset within the stream where the next byte would be read.

return: integer

initBufferFromCurrentChunk()   X-Ref
Initialize the buffer to the current chunk's data.

return: boolean Whether there was a current chunk to read

initBufferFromNextChunk()   X-Ref
Advance to the next chunk and initialize the buffer to its data.

return: boolean Whether there was a next chunk to read

initChunksIterator()   X-Ref
Initializes the chunk iterator starting from the current offset.